Changes between Version 113 and Version 114 of DeveloperGuidelinesTesting


Ignore:
Timestamp:
08/08/11 21:23:22 (13 years ago)
Author:
Mike A
Comment:

highlight examples of running tests

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelinesTesting

    v113 v114  
    7979 * sloppy tests are as bad or worse than sloppy code - unit tests are not a silver bullet or a free lunch,
    8080
    81 === Running unit tests ===
     81=== Test Runner ===
     82
     83[http://readthedocs.org/docs/nose/ nose] is a python module/command which finds and runs tests. nose is suitable as it has been widely adopted in the python community, allows standard test specifications and is highly configurable and customisable, without confusing "magical" behaviour.
    8284
    8385Web2py imposes a severe problem on any external test runner, i.e. application code is provided a global environment by web2py, it must expect that environment. Therefore, the test runner must reproduce and provide that environment to the tests. This means that we can't use any external test runner that doesn't know about web2py.
    84 
    85 [http://readthedocs.org/docs/nose/ nose] is a python module/command which finds and runs tests. nose is suitable as it has been widely adopted in the python community, allows standard test specifications and is highly configurable and customisable, without confusing "magical" behaviour. Documentation is [http://readthedocs.org/docs/nose/ here].
    8686
    8787To cope with web2py, a wrapper and a plugin has been written, which means that nosetests isn't run in the normal way, although we'll aim for that as much as possible. Extra arguments are just passed on to nose by the wrapper command, so the command's argument format is the same as that of the original nosetest command.
     
    124124* Read this too: [http://ivory.idyll.org/articles/nose-intro.html]
    125125
    126 === Examples ===
     126=== Running unit tests ===
    127127Assume our current directory is web2py/, which contains the applications folder.
    128128
    129129To run all unit tests:
    130 {{{ ./application/trunk/tests/nose.py }}}
     130{{{
     131./application/trunk/tests/nose.py
     132}}}
    131133
    132134Currently these tests are stored in {{{/tests}}}. The nose plugin will look for tests in this folder. To select tests, give a file or folder path relative to the tests folder.
    133135
    134136For example, there is a gis folder containing tests for the GIS mapping code. To run these particular tests:
    135 {{{ ./application/trunk/tests/nose.py gis }}}
     137{{{
     138./application/trunk/tests/nose.py gis
     139}}}
    136140
    137141Particular python version. Nose.py runs the tests with whichever python version ran it. It will use /usr/bin/python if run as an ordinary command as above. To select a different python version run (e.g. python 2.5):
    138 {{{ /path/to/python2.5 ./application/trunk/tests/nose.py }}}
     142{{{
     143/path/to/python2.5 ./application/trunk/tests/nose.py
     144}}}
    139145
    140146This may be useful to test different versions but also installed modules. N.B. No testing has been done with virtualenv as of this time.