pytest(十)

Allure2生成测试报告

首先我们先用pip安装插件

> pip install allure-pytest

然后我们去下载最新版本的allure2,连接:https://bintray.com/qameta/maven/allure2

下载完之后我们解压到python安装目录下,如下图:pytest(十)

然后我们找到allure.bat,并配置环境变量到path,allure.bat目录如下:pytest(十)

配置完环境变量后,我们来验证一下,进入命令窗口,输入:allure --version

pytest(十)

环境安装好了,那么我们来验证一下,用例就用咱们之前写好的就可以,直接命令运行

> pytest -m webtest --alluredir report

pytest(十)

运行完之后,会在同级目录下创建个report文件夹,并在文件夹中生成xml报告,我们想要查看这个报告的话有两种方法,

一、直接命令运行     > allure serve report

这个时候它会自动打开测试报告

二、命令运行            > allure generate report/ -o report/html

运行完之后,会在report文件夹下生成一个html,我们可以在文件夹下找到   index.html   ,如果我们从文件夹直接打开这个网页会出现问题,我们直接在pycharm中打开就可以了

pytest(十)