Allure生成测试报告

Allure 使用

安装 adapter

如果要在 pytest 中使用 Allure,需要使用一个 Adaptor

Allure Pytest Adaptor

安装 pytest-allure-adaptor

pip3 install pytest-allure-adaptor

生成报告

还是基于我们上一篇讲解 pytest 所写的代码

现在我们需要做的只是一行命令!在执行原先的命令之后加一句配置即可

pytest -s -q --alluredir report
或者
pytest -s -q --alluredir [path_to_report_dir]

这时候你就会发现用例执行完成之后会在当前目录下生成了一个report文件

打开xml会发现一堆乱七八糟的东西.坑爹呢.说好的报告美观呢?(掀桌

这个文件夹的东西很重要,最终生成好看的报告就是靠他们.但再生成之前需要先装一个生成工具

生成好看的报告

生成工具有很多种,相关文档可以参考下面

Generating a report

它支持 gradle Plugin ,Jenkins Plugin等等.这里我们简单的使用 Command 的方式生成报告.

安装 Command Tool

allure-commandline下载链接

https://github.com/allure-framework/allure1/releases/download/allure-core-1.5.2/allure-commandline.zip

下载解压缩即可使用

生成 Report

allure generate directory-with-results/ -o directory-with-report
这里我们的命令是
allure generate report/ -o report/html

最终报告会生成在 report/html 目录下

打开 index.html,之前写的 case 报告就会呈现在你面前

注:直接用chrome浏览器打开报告,报告会是空白页面,解决办法,在pycharm中右击index.html选择打开方式Open in Browser就可以了

 

posted @ 2018-01-30 17:37  悠然现南山  阅读(21814)  评论(2编辑  收藏  举报