| 639 | === Announcement: Testing framework now in trunk === |
| 640 | |
| 641 | I moved testing framework ([source:grass/trunk/lib/python/gunittest?rev=61225 gunittest] package) from sandbox to trunk in |
| 642 | r61225. |
| 643 | |
| 644 | You can run all tests from GRASS source code top directory using: |
| 645 | |
| 646 | {{{ |
| 647 | python -m grass.gunittest.main .../grassdata/ nc_spm_08 nc |
| 648 | }}} |
| 649 | |
| 650 | You should be in GRASS session and in some testing location (it will not be |
| 651 | used but to be sure that nothing is damaged). First parameter is path to |
| 652 | GISDBASE, second is the name of location (you should use sample NC smp |
| 653 | location) and third parameter should be 'nc'. Running tests may take few |
| 654 | minutes and then open a file `testreport/index.html` with test results. |
| 655 | |
| 656 | I'm working on [source:grass/trunk/lib/python/docs/src/gunittest_testing.rst?rev=61228 documentation] but assertion methods are well documented already and there is already a lot of examples in the source code. See directories named testsuite for example test files (ignore testsuite directory in root for now). Modules which have tests are [source:grass/trunk/temporal/t.rast.extract/testsuite t.rast.extract], [source:grass/trunk/raster/r.gwflow/testsuite r.gwflow], [source:grass/trunk/general/g.mlist/testsuite g.mlist], [source:grass/trunk/general/g.mremove/testsuite g.mremove], [source:grass/trunk/general/g.list/testsuite g.list], and [source:grass/trunk/raster/r.slope.aspect/testsuite r.slope.aspect]. |
| 657 | |
| 658 | You can write tests for raster modules pretty easily and in limited way it |
| 659 | is possible to write tests for vector modules too. See the available assert |
| 660 | methods (in [source:grass/trunk/lib/python/gunittest/case.py?rev=61225 gunittest] and in [https://docs.python.org/2/library/unittest.html#assert-methods unittest]). When writing consider that you are in GRASS sample NC spm location. |
| 661 | |
| 662 | Tests for modules such as `r.info` or `r.univar` are good starting point in |
| 663 | learning how to write tests and moreover, it would be advantageous to have |
| 664 | these core modules covered. If you would prefer rewriting rather then |
| 665 | writing, there is a lot of tests (or Pythod doctests) here and there which |
| 666 | might be integrated into the new framework. I can give you some pointers. |
| 667 | |
| 668 | I'm getting feedback from Soeren but I would like to hear from other |
| 669 | developers, too. So, let me know what you think. |
| 670 | |
| 671 | [http://lists.osgeo.org/pipermail/grass-dev/2014-July/069988.html announcement email] |