[英]How to run specific test in Nose2
在以前版本的Nose测试框架中,有几种方法只能指定所有测试的子集:
nosetests test.module
nosetests another.test:TestCase.test_method
nosetests a.test:TestCase
nosetests /path/to/test/file.py:test_function
http://nose.readthedocs.org/en/latest/usage.html#selecting-tests
但是,我找不到有关Nose2中类似测试选择的任何信息。 在文档中提到了不同的测试发现,但这似乎并不相关。
有没有办法在nose2或(更一般地)unittest2中选择特定的测试或测试用例?
我在开发/测试中有一些测试,例如:
dev/tests/test_file.py
我可以用以下方式运行:
nose2 -s dev tests.test_file
另外,我能够在测试用例中运行特定的测试方法,如下所示:
nose2 -s dev tests.test_file.TestCase.test_method
这会实现你想要的吗?
您必须使用配置文件:
nose2 -c nose2.cfg
nose2.cfg:
[unittest]
start-dir=test/module
如果您正在考虑编写将修改该配置文件并重新运行鼻子测试的脚本,您可能只想运行所有测试。 单元测试应该非常快......但如果您只关注特定的测试部分,那么跳转到此文件并在开发期间更改该行是值得的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.