Skip to content Skip to sidebar Skip to footer

Run Python Unittest When Only Testcase Imported

I have inherited a testing directory that looks like this: tests | this_test | __init__.py | this_test.py | that_test | __init__.py | that_test.py Where the

Solution 1:

You can use nosetests coming from package nose to discover and run your tests. It is very useful to collect and run all tests, even coming from docstring. Also, you can generate JUnit XML report with it.

pip install nose
# Show all nosetests options
nosetests --helpcd tests
nosetests

Solution 2:

You can use nose for running the tests, and start the name of your test files with 'test_' , so that nose can discover the test files and test inside them.

Example - test_this.py

Post a Comment for "Run Python Unittest When Only Testcase Imported"