美文网首页
Python&selenium 自动化测试框架之Allure生成

Python&selenium 自动化测试框架之Allure生成

作者: 乘风破浪的姐姐 | 来源:发表于2022-08-17 11:01 被阅读0次

Python+selenium自动化测试框架生成allure测试报告
1、 官网下载allure https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/

image.png

2、解压安装包,allure的bin路径添加至环境变量


image.png

3、cmd,确认allure版本号: allure --version


image.png

4、pyCharm安装allure-pytest插件:pip install allure-pytest

5、在项目根目录运行pytest用例生成allure报告


image.png

pytest.ini 源码:

[pytest]
addopts =-vs --alluredir ./temp --clean-alluredir
testpaths = ./testcase
python_files = test_*.py
python_functions = test_*
python_classes = Test*

6、执行测试

import os

if __name__ == '__main__':
 
    # 第一步:生成json格式临时文件
    pytest.main(['-vs',r'D:\Python\project\xxx_auto\testcase','--alluredir','./temp','--clean-alluredir'])
    # 第二步:根据json格式临时文件生成allure报告
    os.system("allure generate ./temp -o ./report --clean")

7、生成测试报告,打开index.html即可


image.png
image.png

过程中遇到的问题:
1、pyCharm运行,控制台输出乱码
设置Settings--Editor---File Encodings如下:


image.png

2、报错:‘allure’ 不是内部或外部命令,也不是可运行的程序或批处理文件。
1)allure的版本和allure-pytest插件版本号尽量保持一致,例如:allure:2.8.1
allure-pytest: 2.8.1

  1. 配置完allure的环境变量后,重启pyCharm,如果打开了多个窗口,都需要关闭

相关文章

网友评论

      本文标题:Python&selenium 自动化测试框架之Allure生成

      本文链接:https://www.haomeiwen.com/subject/yoqdgrtx.html