• pytest文档75


    前言

    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
    
  • 相关阅读:
    absolute 导致点击事件无效
    windows 下的命令操作
    localStorage 设置本地缓存
    css渐变
    vue-cli webpack全局引入jquery
    #024分段函数。
    #023单词接龙1(字符串)(女友)
    #022 Python 实验课
    #021 Java复习第一天
    #020PAT 没整明白的题L1-009 N个数求和 (20 分)
  • 原文地址:https://www.cnblogs.com/yoyoketang/p/15042390.html
Copyright © 2020-2023  润新知