I use nose and coverage as testing stack.
I run the test chain like below:
(worker)pc16:task-worker julio$ fab localhost test
[localhost] Executing task 'test'
[localhost] local: nosetests --with-coverage --cover-package=task_workers --cover-html
................
Name Stmts Miss Cover Missing
---------------------------------------------------------------------------------------------
task_workers 0 0 100%
task_workers.mobile_interface 0 0 100%
task_workers.mobile_interface.abstract_mobile_interface 22 0 100%
task_workers.mobile_interface.mobile_interface_factory 12 0 100%
task_workers.mobile_interface.openvox 0 0 100%
task_workers.mobile_interface.virtual_network 0 0 100%
task_workers.mobile_interface.virtual_network.virtual_network 46 9 80% 28-29, 31, 42-43, 45, 57-58, 60
task_workers.task 0 0 100%
task_workers.task.shell 0 0 100%
task_workers.task.shell.shell 21 0 100%
task_workers.task.shell.shell_validator 20 0 100%
task_workers.task.task_factory 9 0 100%
task_workers.task_workers 23 0 100%
task_workers.util 0 0 100%
task_workers.util.exception 12 0 100%
---------------------------------------------------------------------------------------------
TOTAL 165 9 95%
----------------------------------------------------------------------
Ran 16 tests in 0.265s
OK
Done.
Point is that I have easily a good code coverage with nose and coverage as I have some global tests for the main functions.
How is it possible to compute the code coverage class by class to be sure that the code is tested unitary and not just called by a parent class?
2 Answers 2
From the coverage perspective, it does not matter whether a particular line of code is executed from a parent class or some specific class. So you already in a very good shape! If you want to find something to worry about, try branch coverage measurement
2 Comments
Coverage.py doesn't offer a feature to tell you what you want. The best you can do now is to run tests in smaller batches: if you want to know the coverage in class Foo from the tests in test_foo.py, then run only test_foo.py, and see what the coverage is.
If you have ideas about how this could be made easier, I'm interested to hear them.