0

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?

asked Jul 16, 2014 at 13:16

2 Answers 2

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

answered Jul 17, 2014 at 0:02
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I think there is one drawback: if I want to re-use a module in another program and the coverage of this module is done by a parent test module, the other program will not get the benefits of the test and will have to write another one.
@Julio If you are simply re-using a module, then you have to be satisfied with the existing tests. The tests for your new program should just cover the new program and not the module being reused.
0

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.

answered Jul 17, 2014 at 10:59

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.