在我正在处理的项目中的数千个测试用例中,有(大约 10 个)测试很可能会失败(因为它们测试的东西很容易被破坏)。为了使测试快速失败,我想让它们先运行。
我知道--failed-first和排序插件- 两者都有帮助,但不完全满足我的要求:我希望 pytest 能够了解过去失败的所有测试 - 不仅在最后一次运行中,而且如果能够让 pytest 发现这些情况(而不是手动指定它们。
那么有没有一种方法可以实现--failed-most-often-in-the-past呢?
你怎么做到这一点?
目前的方法
通过手动收集失败的测试,您可以先运行它们,只需将它们放在要运行的测试前面即可:
time pytest -x tests/some/generic/test_file.py::failing_test tests
Run Code Online (Sandbox Code Playgroud)
比
time (pytest -x tests/some/generic/test_file.py::failing_test; pytest -x tests)
Run Code Online (Sandbox Code Playgroud)
您现在可以自动收集失败的测试并将它们添加到文件中:
pytest -x $(cat failing_tests.txt) tests
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
215 次 |
| 最近记录: |