首页 > 其他 > 详细

pytest文档75 - 生成 junit-xml 测试报告

时间:2021-07-22 11:25:00      阅读:15      评论:0      收藏:0      [点我收藏+]

前言

pytest 生成junit-xml 测试报告,那么生成的xml报告有什么用呢?可以集合一些持续集成工具(如jenkins...等)方便查看报告。

junit-xml 测试报告

命令行参数有2个跟 junit-xml 报告相关的参数

  --junit-xml=path      create junit-xml style report file at given path.
  --junit-prefix=str    prepend prefix to classnames in junit-xml output

--junit-xml 指定报告保存地址,使用示例

> pytest demo --junit-xml=./report.xml

运行后会在当前目录生成一个report.xml格式报告

技术分享图片

--junit-prefix 设置xml报告的class属性,使用示例

> pytest demo --junit-xml=./report.xml --junit-prefix=xxx

技术分享图片

pytest.ini配置

pytest.ini配置有5个人参数可以配置

  junit_suite_name (string):
                        Test suite name for JUnit report
  junit_logging (string):
                        Write captured log messages to JUnit report: one of no|log|system-out|system-err|out-err|all
  junit_log_passing_tests (bool):
                        Capture log information for passing tests to JUnit report:
  junit_duration_report (string):
                        Duration time to report: one of total|call
  junit_family (string):
                        Emit XML for schema: one of legacy|xunit1|xunit2

junit_suite_name 参数可以修改JUnit报告的名称,使用示例,在pytest.ini配置文件添加

[pytest]

junit_suite_name=yoyo

运行后会在xml报告中修改testsuite中的name属性

技术分享图片

在命令行中也可以通过传参-o junit_suite_name也可以改变testsuite中的name属性

> pytest demo --junit-xml=./report.xml -o junit_suite_name

pytest文档75 - 生成 junit-xml 测试报告

原文:https://www.cnblogs.com/yoyoketang/p/15042390.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!