353 | | The [https://docs.python.org/2/library/unittest.html#unittest.TestLoader.discover unittest.TestLoader.discover] function requires that module names ''are importable (i.e. are valid Python identifiers)''. Consequently, names of files with tests should contain dots (except for the `.py` suffix). |
354 | | |
355 | | Methods with tests must start with `test_` to be recognized by the [https://docs.python.org/2/library/unittest.html#organizing-test-code unittest] framework (with default setting but there is no reason to not keep this convention). |
| 353 | Methods with tests must start with `test_` to be recognized by the [https://docs.python.org/2/library/unittest.html#organizing-test-code unittest] framework (with default setting but there is no reason to not keep this convention). This method is called ''test method''. |
| 354 | |
| 355 | The test methods testing one particular topic are in one ''test case'' (`TestCase` class child). From another point of view, one ''test case'' class contains all tests which requires the same setup and teardown. |
| 356 | |
| 357 | Names of files with tests should not contain dots (except for the `.py` suffix) because the [https://docs.python.org/2/library/unittest.html#unittest.TestLoader.discover unittest.TestLoader.discover] function requires that module names ''are importable (i.e. are valid Python identifiers)''. One file is a module in Python terminology, so we can say ''test module'' to denote a file with tests. However, we want these files to be executable, so this might lead also to the name ''test script''. |
| 358 | |
| 359 | A ''test suite'' is a group of test cases or more generally tests (test methods, test cases and other test suites in one or more files). A `unittest`'s `TestSuite` class is defined similarly. |
| 363 | The preparation of the test is called ''setup'' or ''set up'' and the cleaning after the test is called ''teardown'' or ''tear down''. There are `setUp`, `setUpClass`, `tearDown` and `tearDownClass` methods in `TestCase` class. |
| 364 | |
| 365 | It is not clear how to call a custom script, class or function which will invoke the tests. ''Test runner'' would be appropriate but there is also `TestRunner` class in `unittest` package. Also, a ''report'' is a document or set of documents, however the class in `unittest` representing or creating the report is called `TestResult`. |
| 366 | |
| 367 | The package with GRASS-specific testing functions and classes can be called `gunittest` (since it is based on `unittest`), `gtestsuite` (`testsuite` is reserved for the directory with tests), `gtest`, `test`, `tests` or `grasstest`. This package will be part of GRASS main package, so import will look like (using `gtest`): |
| 368 | |
| 369 | {{{ |
| 370 | #!python |
| 371 | from grass import gtest |
| 372 | from grass.gtest import compare_rasters |
| 373 | }}} |