Reputation: 531
I am using nosetests --with-coverage to test and see code coverage of my unit tests. The class that I test has many external dependencies and I mock all of them in my unit test.
When I run nosetests --with-coverage, it shows a really long list of all the imports (including something I don't even know where it is being used).
I learned that I can use .coveragerc for configuration purposes but it seems like I cannot find a helpful instruction on the web.
My questions are.. 1) In which directory do I need to add .coveragerc? How do I specify the directories in .coveragerc? My tests are in a folder called "tests".. /project_folder /project_folder/tests
2)It is going to be a pretty long list if I were to add each in omit= ... What is the best way to only show the class that I am testing with the unittest in the coverage report?
It would be nice if I could get some beginner level code examples for .coveragerc. Thanks.
Upvotes: 2
Views: 2117
Reputation: 404
You can also use the --cover-package=PACKAGE
option. For example:
nosetests --with-coverage --cover-package=module_you_are_testing
See http://nose.readthedocs.org/en/latest/plugins/cover.html for details.
Upvotes: 0
Reputation: 375574
The simplest way to direct coverage.py's focus is to use the source
option, usually source=.
to indicate that you only want to measure code in the current working tree.
Upvotes: 1