目录
查看帮助文档
- allure --help
- 格式:allure [options] [command] [command options]
Usage: allure [options] [command] [command options]
Options:
--help
Print commandline help. 帮助文档
-q, --quiet
Switch on the quiet mode. 安静模式
Default: false
-v, --verbose
Switch on the verbose mode. 冗长模式
Default: false
--version
Print commandline version. 版本
Default: false
Commands:
generate Generate the report
Usage: generate [options] The directories with allure results
Options:
-c, --clean
Clean Allure report directory before generating a new one. 删除allure报告生成的目录
Default: false
--config
Allure commandline config path. If specified overrides values from
--profile and --configDirectory.
--configDirectory
Allure commandline configurations directory. By default uses
ALLURE_HOME directory.
--profile
Allure commandline configuration profile.
-o, --report-dir, --output allure报告目录
The directory to generate Allure report into.
Default: allure-report
serve Serve the report
Usage: serve [options] The directories with allure results
Options:
--config
Allure commandline config path. If specified overrides values from
--profile and --configDirectory.
--configDirectory
Allure commandline configurations directory. By default uses
ALLURE_HOME directory.
-h, --host
This host will be used to start web server for the report.
-p, --port
This port will be used to start web server for the report.
Default: 0
--profile
Allure commandline configuration profile.
open Open generated report
Usage: open [options] The report directory
Options:
-h, --host
This host will be used to start web server for the report.
-p, --port
This port will be used to start web server for the report.
Default: 0
plugin Generate the report
Usage: plugin [options]
Options:
--config
Allure commandline config path. If specified overrides values from
--profile and --configDirectory.
--configDirectory
Allure commandline configurations directory. By default uses
ALLURE_HOME directory.
--profile
Allure commandline configuration profile.
generate 命令行参数
- 作用:生成 allure 的html 报告
- 格式:generate [options] allure报告目录
命令行选项
- -c, --clean : 删除allure之前生成的报告目录
- -o, --report-dir, --output :生成allure报告目录,默认为allure-report
open 命令行参数
- 作用:打开生成的 allure 报告,就是打开 generate 命令生成的报告
- 格式:open [options] allure报告目录
命令行选项
- -h, --host : 启动报告的web服务器IP
- -p, --port : 启动报告的web服务器端口
serve 命令行参数
- 作用:启动 allure 服务,打开 allure 报告
- 格式:serve [options] allure报告目录
打开报告两种方式
- 方式1:allure serve 报告目录
# -*- coding: utf-8 -*-
# @Time : 2021/12/18
# @Author : 大海
import os
def test_1():
print('这是case1')
def test_2():
print('这是case2')
if __name__ == '__main__':
# 运行pytest,--alluredir 指定报告结果目录为 allure-report
os.system('pytest -sq test_43.py --alluredir=./allure-report')
# 打开allure报告 (目录与上面生成结果目录需一致)
os.system('allure serve ./allure-report')
- 方式2:allure generate + allure open 报告目录
# -*- coding: utf-8 -*-
# @Time : 2021/12/18
# @Author : 大海
import os
import time
def test_1():
print('这是case1')
def test_2():
print('这是case2')
if __name__ == '__main__':
# 运行pytest,--alluredir 指定报告结果目录为 allure
os.system('pytest -sq test_44.py --alluredir=./allure')
# 生成HTML报告 -c 删除上次报告 -o 指定HTML报告路径 ./allure 是用户生成HTML报告的文件信息,是上一步骤生成的
os.system('allure generate -c -o ./allure-report ./allure')
# 打开allure报告 (目录与上面生成HTML报告目录一致)
os.system('allure open ./allure-report')