前言
allure支持往测试报告中对测试用例添加非常详细的描述语用来描述测试用例详情;这对阅读测试报告的人来说非常的友好,可以清晰的知道每个测试用例的详情。
allure添加描述的三种方式:
- 使用装饰器@allure.description,传递一个字符串参数来描述测试用例。
- 使用装饰器@allure.description_html,传递一段HTML文本,这将在测试报告的“Description”部分渲染出来。
- 直接在测试用例方法中通过编写文档注释的方法来添加描述。
实例
# file_name: test_description.py
import pytest
import allure
@allure.description("""
多行描述语:
这是通过传递字符串参数的方式添加的一段描述语,
使用的是装饰器@allure.description
""")
def test_description_provide_string():
assert True
@allure.description_html("""
<h1>Test with some complicated html description</h1>
<table style="width:100%" border="1">
<tr>
<th>Name</th>
<th>Age</th>
<th>