pytest allure添加環(huán)境信息實(shí)例講解
前言
本篇來學(xué)習(xí)下在allure中如何添加環(huán)境信息
properties文件
在allure的report根目錄下添加一個(gè) environment.properties 文件,allure報(bào)告就會(huì)顯示在報(bào)告中
Author=DH
NativePlace=Liaoning
City=Beijing
Age=28
Professional=Test Engineer
Blog=http://www.dbjr.com.cn/
編寫case
# -*- coding: utf-8 -*- import os import shutil def test_1(): print('這是case1') def test_2(): print('這是case2') if __name__ == '__main__': # 運(yùn)行pytest,--alluredir 指定報(bào)告結(jié)果目錄為 allure-report os.system('pytest -sq test_69.py --alluredir=./allure-report --clean-alluredir') # 這里是在項(xiàng)目根路徑下創(chuàng)建的environment.properties文件拷貝到allure-report報(bào)告中,保證環(huán)境文件不會(huì)被清空 shutil.copy('./environment.properties', './allure-report/environment.properties') # 打開allure報(bào)告 (目錄與上面生成結(jié)果目錄需一致) os.system('allure serve ./allure-report')
運(yùn)行case,查看報(bào)告
xml文件
- 在allure的report根目錄下添加一個(gè) environment.xml文件,allure報(bào)告就會(huì)顯示在報(bào)告中
- environment.xml
<environment> <parameter> <key>Author</key> <value>DH</value> </parameter> <parameter> <key>NativePlace</key> <value>Liaoning</value> </parameter> <parameter> <key>City</key> <value>Production</value> </parameter> <parameter> <key>Age</key> <value>28</value> </parameter> <parameter> <key>Professional</key> <value>Test Engineer</value> </parameter> <parameter> <key>Blog</key> <value>http://www.dbjr.com.cn/</value> </parameter> </environment>
編寫case
# -*- coding: utf-8 -*- import os import shutil def test_1(): print('這是case1') def test_2(): print('這是case2') if __name__ == '__main__': # 運(yùn)行pytest,--alluredir 指定報(bào)告結(jié)果目錄為 allure-report os.system('pytest -sq test_69.py --alluredir=./allure-report --clean-alluredir') shutil.copy('./environment.xml', './allure-report/environment.xml') # 打開allure報(bào)告 (目錄與上面生成結(jié)果目錄需一致) os.system('allure serve ./allure-report')
查看報(bào)告
到此這篇關(guān)于pytest allure添加環(huán)境信息實(shí)例講解的文章就介紹到這了,更多相關(guān)pytest allure環(huán)境信息內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
在matplotlib的圖中設(shè)置中文標(biāo)簽的方法
今天小編就為大家分享一篇在matplotlib的圖中設(shè)置中文標(biāo)簽的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-12-12python通用數(shù)據(jù)庫操作工具 pydbclib的使用簡介
這篇文章主要介紹了python通用數(shù)據(jù)庫操作工具 pydbclib的使用簡介,幫助大家更好的理解和使用python,感興趣的朋友可以了解下2020-12-12python實(shí)現(xiàn)對(duì)svn操作及信息獲取
這篇文章主要介紹了python實(shí)現(xiàn)對(duì)svn的操作及信息獲取示例過程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步2021-10-10Python實(shí)現(xiàn)灰色關(guān)聯(lián)分析與結(jié)果可視化的詳細(xì)代碼
今天小編通過代碼以灰色色系為例給大家介紹Python灰色關(guān)聯(lián)分析實(shí)現(xiàn)方法,灰色關(guān)聯(lián)度分析對(duì)于一個(gè)系統(tǒng)發(fā)展變化態(tài)勢(shì)提供了量化的度量,非常適合動(dòng)態(tài)歷程分析,感興趣的朋友一起看看吧2022-03-03python錄音并調(diào)用百度語音識(shí)別接口的示例
這篇文章主要介紹了python錄音并調(diào)用百度語音識(shí)別接口的示例,幫助大家更好的理解和利用python處理音頻,感興趣的朋友可以了解下2020-12-12