[英]nosetests coverage and unitary tests
I use nose
and coverage
as testing stack. 我使用
nose
和coverage
作为测试堆栈。 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. 重点是,由于对主要功能进行了一些全局测试,因此我对
nose
和coverage
代码覆盖率很容易。
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? 如何按类计算代码覆盖率类,以确保代码经过单一测试,而不仅仅是由父类调用?
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
如果您想找点担心的地方,请尝试分支覆盖率测量
Coverage.py doesn't offer a feature to tell you what you want. Coverage.py没有提供告诉您所需内容的功能。 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.
现在最好的方法是小批量运行测试:如果要从test_foo.py中的测试中了解Foo类的覆盖范围,则仅运行test_foo.py,然后查看覆盖范围。
If you have ideas about how this could be made easier, I'm interested to hear them. 如果您对如何简化此操作有任何想法,我很想听听他们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.