Tuesday 9 October 2012

How to run multiple python test cases

If you have the following situation: multiple python test cases in a directory and you want to automatically run them with only one command, first you need to install the discover python module, which is actually called python nose module. In Ubuntu you would typically run the following from command line:


$ sudo apt-get install python-nose

After successfully installing the discovery module, navigate to the folder where your test cases are located and just run:

$ nosetests

This will automatically find the tests and run them for you. 

Note: I believe that the test file names need to follow a convention; please consult the documentation of the module. I tried with "name_test.py" and it worked.

No comments:

Post a Comment