2 回答

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個(gè)贊
Allure 當(dāng)然更適合您的需求,因?yàn)樗哂?pytest 的所有測試報(bào)告功能(步驟、功能、故事等)。但它是用 java 編寫的,您需要在本地安裝 pytest allure 以及 allure 二進(jìn)制文件才能使其工作。而且您可能需要跳幾下才能使其在您現(xiàn)有的 pytest 代碼庫中工作。
如果您想使用 pytest-html 生成測試步驟,這是一個(gè)可能的解決方案:
# Contents of top level conftest.py
import pytest
@pytest.fixture(scope='session', autouse=True)
def step(request):
@pytest.mark.optionalhook
def pytest_html_results_table_html(request, report, data):
data.append(html.div(str(request.param), class_='Step'))
#Contents of fixture or test code
def test_a(step):
step("abc")
assert True
我沒有在本地運(yùn)行代碼,但這就是添加步驟的最終代碼應(yīng)該是什么樣子。

TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊
添加回答
舉報(bào)