目录:导读
前言
pytest 结合 allure 描述用例的时候我们一般使用 @allure.title 和 @allure.description 描述测试用例的标题和详情。
在用例里面也可以动态更新标题和详情,使用allure.dynamic方法实现。
allure.dynamic 动态属性
feature 模块
allure.dynamic.feature(feature_name)
功能点 story
allure.dynamic.story(case_story)
用例标题 title
allure.dynamic.title(case_title)
用例描述:请求URL 请求类型 期望结果 实际结果描述
desc = "<font color='red'>请求URL:</font>{}<Br/>" \
"<font color='red'>请求类型:</font>{}<Br/>" \
"<font color='red'>期望结果:</font>{}<Br/>" \
"<font color='red'>实际结果描述:</font>{}<Br/>".format(url,method,expect,expect_result)
allure.dynamic.description(desc)
description 用例描述
可以在测试主体内部动态更新描述 allure.dynamic.description
import allure
@allure.description("""
This description will be replaced at the end of the test.
""")
def test_dynamic_description():
assert 42 == int(