[GRASS-dev] Testing framework now in trunk

Vaclav Petras wenzeslaus at gmail.com
Wed Jul 9 21:02:07 PDT 2014

Hi all,

I moved testing framework (gunittest package) from sandbox to trunk in
r61225 [1, 2].

You can run all tests from GRASS source code top directory using:

 python -m grass.gunittest.main .../grassdata/ nc_spm_08 nc

You should be in GRASS session and in some testing location (it will not be
used but to be sure that nothing is damaged). First parameter is path to
GISDBASE, second is the name of location (you should use sample NC smp
location) and third parameter should be 'nc'. Running tests may take few
minutes and then open a file testreport/index.html with test results.

I'm working on documentation [3] 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 t.rast.extract,
r.gwflow, g.mlist, g.mremove, g.list, and r.slope.aspect.

You can write tests for raster modules pretty easily and in limited way it
is possible to write tests for vector modules too. See the available assert
methods [4, 5]. When writing consider that you are sample NC spm location.

Tests for modules such as r.info or r.univar are good starting point in
learning how to write tests and moreover, it would be advantageous to have
these core modules covered. If you would prefer rewriting rather then
writing, there is a lot of tests (or Pythod doctests) here and there which
might be integrated into the new framework. I can give you some pointers.

I'm getting feedback from Soeren but I would like to hear from other
developers, too. So, let me know what you think.


[1] http://trac.osgeo.org/grass/browser/grass/trunk/lib/python/gunittest
[2] http://trac.osgeo.org/grass/changeset/61225
(rendered by Trac see Sphinx doc for full documentation)
[5] https://docs.python.org/2/library/unittest.html#assert-methods
[6] http://trac.osgeo.org/grass/wiki/GSoC/2014/TestingFrameworkForGRASS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140710/20681fc8/attachment.html>

More information about the grass-dev mailing list