2

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?

asked Jul 4, 2017 at 12:56

1 Answer 1

2

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
Funk Forty Niner
74.2k14 gold badges71 silver badges146 bronze badges
answered Jul 4, 2017 at 13:41
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.