前言:
最近在研究接口自动化的框架,好的测试报告在整个测试框架起到至关重要的部分。终于被我发现一个超好用的报告框架,不仅报告美观,而且方便 CI 集成。
就是它,就是它:Allure Test Report!!!
先上一张报告效果图:
python 版本及必要库
python 3.5
pytest 3.3.3
pytest-allure-adaptor 1.7.9
一、环境配置
安装 Python 依赖库:
pip3 install pytest
pip3 install pytest-allure-adaptor
安装 Command Tool:
brew tap qatools/formulas
brew install allure-commandline
二、生成 html 报告命令
1、pytest 命令基础上加--alluredir,生成 xml 报告。
pytest -s -q --alluredir [xml_report_path]
//[xml_report_path]根据自己需要定义文件夹,作者定义为:/report/xml
用例执行完成之后会在 [xml_report_path] 目录下生成了一堆 xml 的 report 文件,当然这不是我们最终想要的美观报告。
2、需要使用 Command Tool 来生成我们需要的美观报告。
allure generate [xml_report_path] -o [html_report_path]
//[html_report_path]根据自己需要定义文件夹,作者定义为:/report/html
打开 index.html,之前写的 case 报告就会呈现在你面前
注⚠️:直接用 chrome 浏览器打开报告,报告可能会是空白页面。
解决办法:
1、在 pycharm 中右击 index.html 选择打开方式 Open in Browser 就可以了。
2、使用 Firefox 直接打开 index.html。
三、定制报告
Feature: 标注主要功能模块
Story: 标注 Features 功能模块下的分支功能
Severity: 标注测试用例的重要级别
Step: 标注测试用例的重要步骤
Issue 和 TestCase: 标注 Issue、Case,可加入 URL
1、Features 定制详解 # -*- coding: utf-8 -*-
# @Time : 2018/8/17 上午10:10
# @Author : WangJuan
# @File : test_case.py
impor