24-pytest-allure命令行参数

简介: 24-pytest-allure命令行参数

查看帮助文档

  • allure  --help
  • 格式:allure [options] [command] [command options]
1. Usage: allure [options] [command] [command options]
2.   Options:
3.     --help
4.       Print commandline help.   帮助文档
5.     -q, --quiet   
6.       Switch on the quiet mode.   安静模式
7.       Default: false
8.     -v, --verbose            
9.       Switch on the verbose mode.    冗长模式
10.       Default: false
11.     --version
12.       Print commandline version.    版本
13.       Default: false
14.   Commands:
15.     generate      Generate the report
16.       Usage: generate [options] The directories with allure results
17.         Options:
18.           -c, --clean
19.             Clean Allure report directory before generating a new one.   删除allure报告生成的目录
20.             Default: false
21.           --config
22.             Allure commandline config path. If specified overrides values from
23.             --profile and --configDirectory.
24.           --configDirectory
25.             Allure commandline configurations directory. By default uses
26.             ALLURE_HOME directory.
27.           --profile
28.             Allure commandline configuration profile.
29.           -o, --report-dir, --output    allure报告目录
30.             The directory to generate Allure report into.
31.             Default: allure-report
32. 
33.     serve      Serve the report
34.       Usage: serve [options] The directories with allure results
35.         Options:
36.           --config
37.             Allure commandline config path. If specified overrides values from
38.             --profile and --configDirectory.
39.           --configDirectory
40.             Allure commandline configurations directory. By default uses
41.             ALLURE_HOME directory.
42.           -h, --host
43.             This host will be used to start web server for the report.
44.           -p, --port
45.             This port will be used to start web server for the report.
46.             Default: 0
47.           --profile
48.             Allure commandline configuration profile.
49. 
50. open      Open generated report
51.       Usage: open [options] The report directory
52.         Options:
53.           -h, --host
54.             This host will be used to start web server for the report.
55.           -p, --port
56.             This port will be used to start web server for the report.
57.             Default: 0
58. 
59.     plugin      Generate the report
60.       Usage: plugin [options]
61.         Options:
62.           --config
63.             Allure commandline config path. If specified overrides values from
64.             --profile and --configDirectory.
65.           --configDirectory
66.             Allure commandline configurations directory. By default uses
67.             ALLURE_HOME directory.
68.           --profile
69.             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 报告目录
1. # -*- coding: utf-8 -*-
2. # @Time    : 2021/12/18
3. # @Author  : 大海
4. 
5. import os
6. 
7. 
8. def test_1():
9. print('这是case1')
10. 
11. 
12. def test_2():
13. print('这是case2')
14. 
15. 
16. if __name__ == '__main__':
17. # 运行pytest,--alluredir 指定报告结果目录为 allure-report
18.     os.system('pytest -sq test_43.py --alluredir=./allure-report')
19. # 打开allure报告 (目录与上面生成结果目录需一致)
20.     os.system('allure serve ./allure-report')
  • 方式2:allure generate + allure open 报告目录
1. # -*- coding: utf-8 -*-
2. # @Time    : 2021/12/18
3. # @Author  : 大海
4. 
5. import os
6. import time
7. 
8. 
9. def test_1():
10. print('这是case1')
11. 
12. 
13. def test_2():
14. print('这是case2')
15. 
16. 
17. if __name__ == '__main__':
18. # 运行pytest,--alluredir 指定报告结果目录为 allure
19.     os.system('pytest -sq test_44.py --alluredir=./allure')
20. # 生成HTML报告  -c 删除上次报告   -o 指定HTML报告路径   ./allure 是用户生成HTML报告的文件信息,是上一步骤生成的
21.     os.system('allure generate -c -o ./allure-report ./allure')
22. # 打开allure报告 (目录与上面生成HTML报告目录一致)
23.     os.system('allure open ./allure-report')


相关文章
|
测试技术 Python
Pytest简单介绍
Pytest简单介绍
68 0
|
4月前
|
测试技术 Python
pytest中的fixture和conftest.py
pytest中的fixture和conftest.py
|
XML Java 测试技术
Pytest-测试报告Allure
Pytest-测试报告Allure
315 0
|
JSON 测试技术 数据格式
19-pytest-allure-pytest环境搭建
19-pytest-allure-pytest环境搭建
|
测试技术
pytest conftest.py和fixture的配合使用
pytest conftest.py和fixture的配合使用
|
测试技术
pytest学习和使用9-fixture中conftest.py如何使用?
pytest学习和使用9-fixture中conftest.py如何使用?
125 0
pytest学习和使用9-fixture中conftest.py如何使用?
|
测试技术 Python Windows
|
存储 测试技术 Python
Pytest fixture及conftest详解
fixture关键特性;fixture定义;fixture用法;fixture四种作用域;fixture相关参数;内置fixture示例;
Pytest fixture及conftest详解