pytest钩子函数获取测试用例allure的title
conftest.py写法
import pytest
from allure_pytest.utils import allure_title
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
if report.when == "call":
# 获取 allure title
allure_title_value = allure_title(item)
if allure_title_value:
print(f"Allure Title for {item.name}: {allure_title_value}")
else:
print(f"No Allure Title set for {item.name}")
testcase里面加allure.title
@allure.title('中文用例名称')
def test_login_01(self, beginandend):
self.driver, self.logger = beginandend
lp = LoginPage(self.driver)
lp.login_normal()