nose reports cumulative coverage

102 Views Asked by At

Image a situation where you have a BASE_CLASS. Several class inherits from that class: CHILD_A, CHILD_B, CHILD_C.

Now let us write unit tests, but ONLY for CHILD_A, CHILD_B, CHILD_C. I would suspect, that the coverage for BASE_CLASS is 0%. Unfortunately, nose takes cumulative coverage, which is not what I want. I tried using the ---cover-erase flag while executing the tests, but that doesn't help.

My question is: How can I force nose not to use cumulative coverage? I need this to know how good is the unit test for BASE_CLASS.

1

There are 1 best solutions below

0
On BEST ANSWER

Your tests are running the code in BASE_CLASS. Python doesn't just know what in the base class when creating sub class instances. It has to go to the base class and look at the code there.

If you want to see how good your coverage for that particular base class you can run the test case/method specific to that class. From the docs:

# Run all the tests in the animals.tests module
$ ./manage.py test animals.tests

# Run all the tests found within the 'animals' package
$ ./manage.py test animals

# Run just one test case
$ ./manage.py test animals.tests.AnimalTestCase

# Run just one test method
$ ./manage.py test animals.tests.AnimalTestCase.test_animals_can_speak