前言
properties文件
- 在allure的report根目录下添加一个 environment.properties 文件,allure报告就会显示在报告中
Author=DH
NativePlace=Liaoning
City=Beijing
Age=28
Professional=Test Engineer
Blog=https://blog.csdn.net/IT_heima
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4102766558c3c90b52350d8719641f08.png)
import os
import shutil
def test_1():
print('这是case1')
def test_2():
print('这是case2')
if __name__ == '__main__':
os.system('pytest -sq test_69.py --alluredir=./allure-report --clean-alluredir')
shutil.copy('./environment.properties', './allure-report/environment.properties')
os.system('allure serve ./allure-report')
- 运行case,查看报告
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/aebc56804cbedec76f1bf809a9e82f85.png)
xml文件
- 在allure的report根目录下添加一个 environment.xml文件,allure报告就会显示在报告中
- 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>https://blog.csdn.net/IT_heima</value>
</parameter>
</environment>
import os
import shutil
def test_1():
print('这是case1')
def test_2():
print('这是case2')
if __name__ == '__main__':
os.system('pytest -sq test_69.py --alluredir=./allure-report --clean-alluredir')
shutil.copy('./environment.xml', './allure-report/environment.xml')
os.system('allure serve ./allure-report')
- 查看报告
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/1a5c4c923740574b2e661d4a0c00fbc1.png)