美文网首页
pytest+allure让你的测试报告飞起来

pytest+allure让你的测试报告飞起来

作者: YongpingZhao | 来源:发表于2018-02-14 12:39 被阅读0次

安装allure命令行:
如果是ubuntu:如下安装,如果是其他的,请源码安装,请跳转:https://bintray.com/qameta/generic/allure2

sudo apt-add-repository ppa:qameta/allure
sudo apt-get update 
sudo apt-get install allure

如果是mac:brew install allure
安装pytest以及allure包:

pip install pytest
pip install pytest-allure-adaptor

写完testcase后,生成报告:

 py.test --alluredir=reports
allure generate reports

运行完之后,你会发现多了两个文件夹,一个是reports/,一个是allure-reports/,allure-reports下面有一个index.html。然后在浏览器中打开。如果是chrome中,你会发现404。可以切换到Firefox中查看,不多说,上图。

Overview:

allure_firefox.png

Suites:

allure_suites.png

Graphs:

allure_graphs.png

与jenkins集成

  1. 打开jenkins,系统配置,插件配置,搜索allure,然后安装allure-jenkins-plugin。
  2. 安装allure command-line,系统配置-系统工具配置,安装allure-commandline。https://docs.qameta.io/allure/#_jenkins,既可以maven安装,也可以源码安装,二者选一即可。
  3. Jenkinsfile中添加stage,添加report,
        stage('Report') {
            steps {
                script {
                    allure([includeProperties: false, jdk: '', properties: [], 
                    reportBuildPolicy: 'ALWAYS',results: [[path: 'tests/reports']]
                    ])
                }
            }
        }

相关文章

网友评论

      本文标题:pytest+allure让你的测试报告飞起来

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