From e39c45d8edb18e7c88f92d549f5e0c71d1a930b2 Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Fri, 1 May 2020 19:25:12 -0500 Subject: [PATCH] Draft: update description of drafttests package --- src/Mod/Draft/drafttests/README.md | 44 +++++++++++++++++++++++----- src/Mod/Draft/drafttests/__init__.py | 42 +++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/src/Mod/Draft/drafttests/README.md b/src/Mod/Draft/drafttests/README.md index d6cac829b19a..9d140cd4ee23 100644 --- a/src/Mod/Draft/drafttests/README.md +++ b/src/Mod/Draft/drafttests/README.md @@ -1,23 +1,53 @@ -2020 February +# General + +2020 May These files provide the unit tests classes based on the standard Python `unittest` module. -These files should be imported from the main `TestDraft.py` module -which is the one registered in the program in `InitGui.py`. +These files should be imported from the main `TestDraft.py` +and `TestDraftGui.py` modules which are registered in the program +in `Init.py` and `InitGui.py` depending on if they require +the graphical interface or not. Each module should define a class derived from `unittest.TestCase`, and the individual methods of the class correspond to the individual unit tests which try a specific function in the workbench. The tests should be callable from the terminal. +```bash +# All tests that don't require the graphical interface +program --console -t TestDraft + +# Only creation tests +program --console -t drafttests.test_creation + +# A specific test inside a module and class +program --console -t drafttests.test_creation.DraftCreation.test_line ``` -program -t TestDraft # all tests -program -t drafttests.test_creation # only creation functions -# A specific test -program -t drafttests.test_creation.DraftCreation.test_line +Where `program` is the name of the FreeCAD executable. + +Most tests should be designed to pass even without the graphical interface, +meaning that they should run in console mode. + +The exception to this are particular tests that explicitly use +the graphical interface. +```bash +# All tests that require the graphical interface +program -t TestDraftGui ``` For more information see the thread: [New unit tests for Draft Workbench](https://forum.freecadweb.org/viewtopic.php?f=23&t=40405) + +# To do + +Not every single function in the workbench is tested, so new unit tests +can be written. This will improve reliability of the workbench, +making it easier to discover bugs and regressions. + +See the individual modules to check what is missing. + +In particular, unit tests for the import and export modules (SVG, DXF, DWG) +are required. diff --git a/src/Mod/Draft/drafttests/__init__.py b/src/Mod/Draft/drafttests/__init__.py index 058cb96aefad..7abb26deaa57 100644 --- a/src/Mod/Draft/drafttests/__init__.py +++ b/src/Mod/Draft/drafttests/__init__.py @@ -1,7 +1,41 @@ -"""Classes and functions used to test the workbench. +# *************************************************************************** +# * (c) 2019 Eliud Cabrera Castillo * +# * * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * FreeCAD is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with FreeCAD; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** +"""Modules that define classes used for unit testing the workbench. -These classes are called by the unit test launcher -that is defined in `Init.py` and `InitGui.py`. +These modules contain classes and functions that are called +by the unit test module that is defined in `Init.py` and `InitGui.py`. -The unit tests are based on the standard `unittest` module. +The unit tests are placed in separate modules in order to test features +that do not require the graphical user interface (GUI), from those +that do require it. + +The unit tests are based on the standard Python `unittest` module. +See this module and `unittest.TestCase` for more information +on how to write unit tests. + +:: + + class NewTestType(unittest.TestCase): + def test_new_tool(self): + pass """