pytest+allure生成接口自动化测试报告


准备环境

1、安装pytest  

pip install pytest -i http://pypi.douban.com/simple

 

pytest-ordering

pytest.main([

"-m login",

"-s",  # 输出打印信息

""

])

 

2、安装pytest插件

官网翻译:https://www.jianshu.com/p/f3f13f2e6668

插件汇总:http://plugincompat.herokuapp.com/

pip install pytest-allure-adaptor -i http://pypi.douban.com/simple

 

3、安装allure

  下载地址: https://github.com/allure-framework/allure2

压缩包:https://dl.bintray.com/qameta/maven/io/qameta/allure/allure-commandline/2.12.1/allure-commandline-2.12.1.zip

解压后将allure-2.12.1\bin目录添加到环境变量

 

 验证

 

 

4、执行测试

查看用例目录

 

 在APItesting目录下执行命令

pytest -s -q cases --alluredir reports\xml

-s  允许终端在测试运行时输出结果

-q  简化输出结果

-- alluredir  生成allure指定文件的语法

 

生产这样的文件

 

 5、使用allure命令生成测试报告

allure generate reports\xml -o reports\report
reports\xml  这个目录是执行测试生成的数据
-o reports\report 将测试报告输出保存到这个目录下

最终在report目录下生成以下文件和文件夹

 

 最终在pycharm中打开index.html文件,就可以看到测试报告

 

 

 

参考链接:

https://www.cnblogs.com/hao2018/p/9915044.html

https://www.cnblogs.com/xiaoxi-3-/p/9492534.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM