接口测试 Pytest+allure 生成测试报告

高高 · 2021年03月18日 · 2078 次阅读

Allure

Pytest 是什么

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.
pytest 框架使编写小型测试变得容易,但可以扩展以支持应用程序和库的复杂功能测试。

Windows/Linux allure: command not found

关于没有 allure 命令,是因为 allure 命令需要单独安装。

linux 安装 allure-commandline

  1. Allure requires Java 8 or higher
  2. npm install -g allure-commandline --save-dev

Windows 安装 allure-commandline

allure_git
bin
env

官网给出的

2.1. Installing a commandline
Several options for Allure installation are currently supported:

2.1.1. Linux
For debian-based repositories a PPA is provided:

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

2.1.2. Mac OS X
For Mas OS, automated installation is available via Homebrew

brew install allure

2.1.3. Windows
For Windows, Allure is available from the Scoop commandline-installer.

To install Allure, download and install Scoop and then execute in the Powershell:

scoop install allure

Also Scoop is capable of updating Allure distribution installations. To do so navigate to the Scoop installation directory and execute

\bin\checkver.ps1 allure -u

This will check for newer versions of Allure, and update the manifest file. Then execute

scoop update allure

to install a newer version. (documentation)

生成 allure 测试报告

allure generate /xxx/xxx -o /xxx/xxx --clean

Usage 用法:
generate [options] The directories with allure results. pytest 报告存放目录

-c, --clean

Clean Allure report directory before generating a new one. 每次生成 allure 报告时清除上一次的报告数据。
Default: fals

-o, --report-dir, --output

The directory to generate Allure report into. allure 报告输出地址。
Default: allure-report

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册