How to run specific test in Nose2

假如想象 提交于 2019-12-08 14:52:33

问题


In previous version of Nose testing framework, there were several ways to specify only a subset of all tests:

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

However, I can't find any information about similar test selection in Nose2. There's a mention in docs about different test discovery, but that doesn't seem to be related.

Is there a way to select a specific test or test case in nose2 or (more generally) in unittest2?


回答1:


I have some tests in dev/tests, for example:

dev/tests/test_file.py

I am able to run this with:

nose2 -s dev tests.test_file

Additionally, I'm able to run a specific test method in a test case as follows:

nose2 -s dev tests.test_file.TestCase.test_method

Does that accomplish what you want?




回答2:


You'd have to use a config file:

nose2 -c nose2.cfg

nose2.cfg:

[unittest]
start-dir=test/module

You'd probably want to just run all tests if you're considering writing a script that will modify that config file and re-run your nose tests. Unit tests should be pretty quick...but if you're just focusing on a specific section of tests, it's worth it to jump into this file and change that line during development.



来源:https://stackoverflow.com/questions/17890087/how-to-run-specific-test-in-nose2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!