1、@allure.step()只有一个参数,就是title,你传什么,在allure上就显示什么
举例:
#coding=utf-8
import pytest
import allure
@allure.step("第一步")
def test_01():
pass
2、@allure.attach()
allure报告还支持显示许多不同类型的附件,可以补充测试结果
语法一:allure.attach(body, name, attachment_type, extension)
参数列表
body:要显示的内容(附件)
name:附件名字
attachment_type:附件类型,是 allure.attachment_type 里面的其中一种
extension:附件的扩展名(比较少用)
语法二: allure.attach.file(source, name, attachment_type, extension)
source:文件路径,相当于传一个文件
name:附件名字
attachment_type:附件类型,是 allure.attachment_type 里面的其中一种
extension:附件的扩展名(比较少用)
allure.attachment_type提供了如下附件类型:
allure.attachment_type.TEXT
allure.attachment_type.CSV
allure.attachment_type.TSV
allure.attachment_type.URI_LIST
allure.attachment_type.HTML
allure.attachment_type.JSON
allure.attachment_type.YAML
allure.attachment_type.PCAP
allure.attachment_type.PNG
allure.attachment_type.JPG
allure.attachment_type.SVG
allure.attachment_type.GIF
allure.attachment_type.BMP
allure.attachment_type.TIFF
allure.attachment_type.MP4
allure.attachment_type.OGG
allure.attachment_type.WEBM
allure.attachment_type.PDF
3、@allure.description()
可以添加足够详细的测试用例描述
语法:
@allure.description(str)
@allure.description_html(str) {传html字符串}
4、@allure.title()
为测试用例添加标题,支持占位符传递关键字参数
语法:
@allure.title(str)
5、
@allure.link(url, link_type=LinkType.LINK, name=None)
@allure.issue(url, name=None))
@allure.testcase(url, name=None)
必传参数 url:跳转的链接
举例:
@allure.link('https://www.baidu.com',"百度")
def test_with_link():
pass
6、
@allure.epic(): 敏捷里面的概念,定义史诗,往下是 feature
@allure.feature():功能点的描述,理解成模块往下是 story
@allure.story(): 故事,往下是 title
story 是 feature 的子集,当测试用例有 @allure.feature、@allure.story 时,在报告上会先显示 feature,点开之后再显示 story
# 只运行 epic 名为 test 的测试用例
pytest --alluredir ./report/allure --allure-epics=test
# 只运行 feature 名为 模块 的测试用例
pytest --alluredir ./report/allure --allure-features=模块
# 只运行 story1、story2 的测试用例(也可以不用=号 空格就行了哦)
pytest tests.py --allure-stories story1,story2
# 指定 feature+story
pytest tests.py --allure-features feature2 --allure-stories story2
7、清除旧的用例数据:
# 先运行第一个
pytest test_1.py --alluredir=./allure
# 再运行第二个,此时应该希望 allure 报告只有 test_2.py 的测试用例
pytest test_2.py --alluredir=./allure --clean-alluredir
网友评论