Pytest学习笔记18-allure:清空测试报告
前言
-
使用allure生成测试报告,当报告存放路径相同时,报告数据是会累加,会导致测试报告内展示了之前运行的用例情况
-
同理,当你的用例名称修改后,再次执行后,也会保留上一次的用例运行记录
不同用例文件,报告路径相同
准备 test_report_1.py
和 test_report_2.py
两个用例文件,内容如下:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
__File__ = test_report_1.py
__Project__= _JAuto-Interface
__Time__ = 2022-02-23 15:43:15
__Author__ = 黎晟
"""
def test_case_1_1():
"""测试用例-1-1"""
assert 1 == 1
def test_case_1_2():
"""测试用例-1-2"""
assert 1 == 1
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
__File__ = test_report_2.py
__Project__= _JAuto-Interface
__Time__ = 2022-02-23 15:52:03
__Author__ = 黎晟
"""
def test_case_2_1():
"""测试用例-2-1"""
assert 1 == 1
def test_case_2_2():
"""测试用例-2-2"""
assert 1 == 1
先执行test_report_1.py
文件用例,查看测试报告
# 执行test_report_1.py
pytest --alluredir=./report/xml test_report_1.py
再执行test_report_2.py
文件用例,查看测试报告
# 执行test_report_2.py
pytest --alluredir=./report/xml test_report_2.py
测试报告内会展示历史运行的用例1的内容,这不是想要的结果
相同用例文件,用例名称改变
修改test_report_1.py
用例名称,如下:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
__File__ = test_report_1.py
__Project__= _JAuto-Interface
__Time__ = 2022-02-23 15:43:15
__Author__ = 黎晟
"""
def test_case_11_1():
"""测试用例-11-1"""
assert 1 == 1
def test_case_11_2():
"""测试用例-11-2"""
assert 1 == 1
执行用例(命令同上),查看测试报告
可以看到,test_report_1套件下,共用4条用例,包含了修改用例名称前的用例,也不是想要的结果
–clean-alluredir
用法
- pytest 提供了 --clean-alluredir 命令行参数用来在生产测试报告前,清空历史执行记录
不同用例文件,相同报告路径情况
再次执行
# 执行test_report_1.py
pytest --alluredir=./report/xml test_report_1.py
# 执行test_report_2.py
pytest --alluredir=./report/xml test_report_2.py --clean-alluredir
查看测试报告
可以看到没有其他用例文件的执行记录了
相同用例文件,修改用例名称
同样的修改test_report_1.py文件,
# 修改test_report_1.py文件
def test_case_1_1():
"""测试用例-1-1"""
assert 1 == 1
def test_case_1_2():
"""测试用例-1-2"""
assert 1 == 1
重新运行,查看测试报告
pytest --alluredir=./report/xml test_report_2.py --clean-alluredir
可以看到没有修改前的执行记录了
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhgceaih
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
怎样阻止微信小程序自动打开
PHP中文网 06-13