pytest,诱惑,如何报告自定义缺陷消息

时间:2021-03-02 09:05:22

标签: pytest allure

我有一个测试应用程序,它不需要在断言失败时中断(软检查)。所以我使用 pytest-check 插件,所以我可以有类似的东西:

import pytest_check as check

check.is_true(1 == 2, "Expect 1 but got 2")

但是,有了这个,Allure 报告不会像 assert 1==2, 'Expected 1 but got 2'

那样显示错误消息

conftest.py 中,我有一个 makereport 钩子:

@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    rep = outcome.get_result()
    setattr(item, "rep_" + rep.when, rep)

所以我想知道如何向 Allure 报告提供自定义缺陷消息。请指教。

0 个答案:

没有答案