pytest生成 junit-xml 测试报告

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值