前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >pytest文档75 - 生成 junit-xml 测试报告

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

作者头像
上海-悠悠
发布2021-07-23 15:52:57
1.2K0
发布2021-07-23 15:52:57
举报

前言

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

junit-xml 测试报告

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

代码语言:javascript
复制
  --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 指定报告保存地址,使用示例

代码语言:javascript
复制
> pytest demo --junit-xml=./report.xml

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

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

代码语言:javascript
复制
> pytest demo --junit-xml=./report.xml --junit-prefix=xxx

pytest.ini配置

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

代码语言:javascript
复制
  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配置文件添加

代码语言:javascript
复制
[pytest]

junit_suite_name=yoyo

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

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

代码语言:javascript
复制
> pytest demo --junit-xml=./report.xml -o junit_suite_name
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-07-22,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 从零开始学自动化测试 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • junit-xml 测试报告
  • pytest.ini配置
相关产品与服务
持续集成
CODING 持续集成(CODING Continuous Integration,CODING-CI)全面兼容 Jenkins 的持续集成服务,支持 Java、Python、NodeJS 等所有主流语言,并且支持 Docker 镜像的构建。图形化编排,高配集群多 Job 并行构建全面提速您的构建任务。支持主流的 Git 代码仓库,包括 CODING 代码托管、GitHub、GitLab 等。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档