Consider following python project structure.
Car.py
test_car.py
Van.py
__main__.py
When I run code coverage with nose It only consider files which unit tests are written (i.e. Car.py has a unit tests test_car.py). I used following command to generate the report.
nosetests --with-coverage --cover-erase --cover-html
It generate following coverage report.
.
Name Stmts Miss Cover
----------------------------
Car.py 11 3 73%
----------------------------------------------------------------------
Ran 1 test in 0.007s
OK
But my project have more files (Van.py). But coverage report doesn't contain those files and final coverage percentage doesn't include those. If that report consider all the files, that final percentage will be less than 73%.
How do I generate coverage report by considering all the files. Files without unit test should show 0% code coverage in the report. My project is far more larger than this sample. How do I achive this requirement?
1 Answer 1
It's pretty straight-forward. Damn I didn't RTM. There is a flag --cover-inclusive in order to do that. According to the documentation, "Include all python files under working directory in coverage report. Useful for discovering holes in test coverage if not all files are imported by the test suite. [NOSE_COVER_INCLUSIVE]"
Here how to use it.
nosetests --with-coverage --cover-erase --cover-inclusive --cover-html
Comments
Explore related questions
See similar questions with these tags.