我在使用 py.test 进行单元测试时遇到了一个小问题。
我使用 py.test 运行测试并输出测试的 junitxml 报告。 这个 xml 报告导入到 jenkins 中并生成很好的统计数据。
当我使用从unittest.TestCase派生的测试类时, 我使用以下方法跳过预期的失败:
@unittest.skip("Bug 1234 : This does not work")
选择此测试时,此消息也会显示在 jenkins 中。
当我不使用unittest.TestCase类时,例如使用 py.test 参数化功能, 我使用以下方法跳过预期的失败:
@pytest.mark.xfail(reason="Bug 1234 : This does not work", run=False)
但是这个原因实际上并没有显示在jenkins中,而是会说:
Skip Message
expected test failure
我该如何解决这个问题?
最佳答案
我使用这一行作为测试的第一行解决了它:
pytest.skip("Bug 1234: This does not work")
我宁愿使用 pytest 装饰器之一,但这就可以了。
关于python - Py.test 跳过消息不显示在 Jenkins 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18867280/