有没有办法选择pytest测试从文件运行?
例如,包含要执行的测试列表的文件foo.txt:
tests_directory/foo.py::test_001
tests_directory/bar.py::test_some_other_test
要么
有没有办法从pytest的不同目录中选择多个测试,在测试名称中没有共同的模式?
py.test -k< pattern>允许单一模式.
一种选择是针对每个测试使用pytest.mark,但我的要求是运行来自不同文件的不同测试组合.
有没有办法为每个模式指定多个模式和测试文件名?
或者有没有办法在文件中指定确切的测试路径并将该文件作为pytest的输入提供?
要么
是否有可用于此目的的钩子功能?
解决方法:
您可以使用-k
option运行具有不同模式的测试用例:
py.test tests_directory/foo.py tests_directory/bar.py -k 'test_001 or test_some_other_test'
这将运行名为test_001的测试用例和test_some_other_test,以取消选择其余的测试用例.
Note: This will select any test case starting with test_001 or test_some_other_test. For example, if you have test case test_0012 it will also be selected.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。