当前位置:网站首页>Pytest+allure custom report
Pytest+allure custom report
2022-07-18 17:13:00 【Wang yunao】
Take notes -pytest+allure Custom reports
Part I Foundation :pytest Advanced operations
Test cases are generally data-driven , Advanced point adopts the combination of keywords and data drive , Plus some private customization .
First of all, the number of wingmen allure Parameter configuration , It is generally customized by combining , A single module cannot meet the functional requirements .
Reference resources : article
The first method : Write it in the function ( recommend ), The advantage of this method is that the test cases can be completely separated ,title,severity And other methods are obtained directly from use cases , Operability burst table ; The disadvantage is that the test cases are repetitive
@pytest.mark.parametrize('tid, describe, modules, video_file,args', data) # Use case module
@pytest.mark.flaky(reruns=1) # Failed use case rerun
@allure.step(" First step : Split execution ")
def test_001(index):
allure.dynamic.title(title)# Recyclable acquisition testdata The value in , Realize variable parameter transfer
allure.dynamic.feature(' Function module ')
allure.dynamic.story(' The name of the function ')
allure.dynamic.description(' Test case description ')
allure.dynamic.severity(severity)# Recyclable acquisition testdata The value in , Realize variable parameter transfer
allure.dynamic.tag('p0')
The second method : As a decoration ( Look at the demand choice ), The advantage is that it is significantly high , Name each module uniformly , There is less repetition in some test cases ; The disadvantage is that there is no way to control the level of each test case , And in allure The report shows
@allure.feature(' General basic business support ')
@allure.story('1000: Request to establish a connection ')
@allure.severity('critical')# Cannot cycle from testdata Take reference from
@allure.title('{title}')# Recyclable acquisition testdata The value in , Realize variable parameter transfer
@pytest.mark.parametrize('index,title', list(range(len(testdata))))
def test_001(index,tilte):
pass
Execute generate test report
import pytest
import sys, os
import shutil
dir_path = os.path.dirname(os.path.dirname(__file__))
sys.path.append(dir_path)
Basepath = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
file_name = Basepath + "\\case"
if __name__ == "__main__":
# pytest.main(['-vs'])
# unittest.main()
filename = os.path.dirname(os.path.dirname(__file__))
copy_file = os.path.join(filename, 'config', 'environment.properties')
paste_file = os.path.join(filename, 'result', 'environment.properties')
# shutil.copy(copy_file.replace('\\', '/'), paste_file.replace('\\', '/')) # Replace
test_dir = os.path.dirname(__file__)
pytest.main(['-vs', '-q', file_name, '--alluredir', '../result/', "--clean-alluredir"])
shutil.copy(copy_file, paste_file) # Copy build environment variables
os.system('allure generate ../result/ -o ../report/ --clean')
# os.system('allure open -h 127.0.0.1 -p 8881 ../report/') # Run out , Automatically open the test report
边栏推荐
猜你喜欢

2022年全球职业教育行业发展报告

An expert, Alibaba biggie quit and brought out the internal "high concurrency system design" learning manual

错误:The source of the existing CacheManager is: URLConfigurationSource
US pressure surges tiktok changes global safety director

【华为联机对战】下载运行华为官方Unity示例代码,提示鉴权失败并返回错误码100114

Configure typera+picgo+aliyun OSS service
![[HMS core] [wallet kit] [solution] why can't Huawei wallet's client sample code run](/img/2f/46f9e9b74d2d62701c33d647d8eb9b.png)
[HMS core] [wallet kit] [solution] why can't Huawei wallet's client sample code run

【实战】1382- 一文拥有属于你的 puppeteer 爬虫应用

UE4 blueprint learning chapter (6) -- branch, switch, filpflop, sequence

关于TCP/IP协议漏洞的安全措施
随机推荐
Qt | 控件之QCheckBox
Apple commercial website blocks Firefox browser
越来越难,不行就得多听几次
宝立食品上交所上市:年营收15.78亿 市值58亿
JS writes a foreach method suitable for object objects
【AGD】应用下载直达高频问题合集
[golang] slice
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
PCB芯片散热焊盘如何设计?
[HMS core], [FAQ], [Health Kit] encountered some small problems in the process of integrating sports health services. Today, I share with you (Huawei watch, Bracelet + sports health service problems C
US pressure surges tiktok changes global safety director
C语言位域
配置typora+PicGo+Aliyun OSS服务
交换
畅游奢侈品元宇宙Louis:The Game,参与NFT系列数字藏品白撸活动| 教程
Scala 基础 (二):变量和数据类型
It's getting more and more difficult. If you can't, you have to listen more times
Uncaught Error: Rendered fewer hooks than expected. This may be caused by an accidental early return
基于 CRON 库扩展的分布式 Crontab 的实现
Rapport mondial sur le développement de l'industrie de l'enseignement professionnel 2022