使用taurus junit-xml模块时请求响应数据

问题描述

我正在尝试清理功能测试的jmeter docker + ci管道。我看到taurus有一种在容器中运行jmeter脚本的干净方法,并且下载了我想要的jmeter版本并安装了脚本使用的插件-很棒。

现在,我需要在junit.xml中生成报告,以便使报告保持一致。到目前为止,我使用的是https://github.com/tguzik/m2u修改后的fork来将jtl报告转换为junit.xml

是否对我如何将所有样本的请求,响应(代码和正文)获取到junit.xml(至少对于失败的样本)有帮助?

我尝试了几种金牛座变种...

reporting:
  - module: console
  - module: final_stats
    summary: true
    percentiles: true
    test-duration: true
  - module: junit-xml
    filename: report/report.xml
    data-source: sample-labels

reporting:
  - module: console
  - module: final_stats
    summary: true
    percentiles: true
    test-duration: true
  - module: passfail
  - module: junit-xml
    filename: report/report.xml
    data-source: pass-fail

还在passfail模块上添加了某些passfail标准变体。没有帮助


经过数小时的摆弄之后,我相信没有一种干净的方法可以从taurus的junit-xml模块中获取有意义的内容到junit .xml报告中。看来是准骨。我还注意到,这可能会弄乱认的jenkins junit插件测试结果摘要

所以我选择了以下yaml设置,并继续使用m2u.jar将jtl转换为junit.xml

    modules:
    jmeter:
      path: ~/.bzt/jmeter-taurus/bin/jmeter
      download-link: https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-{version}.zip
      version: 5.3  
      force-ctg: true 
      detect-plugins: true
      plugins:
      - jpgc-json=2.2
      - jmeter-ftp
      - jpgc-casutg
      xml-jtl-flags:
        xml: true
        fieldNames: true
        time: true
        timestamp: true
        latency: true
        connectTime: false
        success: true
        label: true
        code: true
        message: true
        threadName: true
        dataType: false
        encoding: false
        assertions: true
        subresults: true
        responseData: false
        samplerData: false
        responseHeaders: false
        requestHeaders: true
        responseDataOnError: true
        saveAssertionResultsFailureMessage: true
        bytes: true
        threadCounts: false
        url: true

execution:
- write-xml-jtl: full
  scenario:
    script: v_jmxfilename
    properties:
      environment: v_env

reporting:
  - module: console
  - module: final_stats
    summary: true
    percentiles: true
    test-duration: true
#  - module: junit-xml
#    filename: report/junit-report.xml
#    data-source: sample-labels

解决方法

根据JUnit-XML-Reporter文档,目前这是不可能的:

此报告器以Jenkins JUnit插件可解析的JUnit XML格式提供测试结果。记者有两个选择:

  • filename(报告文件的完整路径,可选。默认情况下,工件目录中为xunit.xml)
  • data-source(要使用的数据源:样本标签或通过失败)

如果样本标签用作源数据,则报告将包含带有测试错误的网址。如果通过失败作为源数据,则报告将包含通过/失败标准信息。请注意,必须将通过失败模块放置在报告者列表中,在junit-xml模块之前。

Taurus不仅适用于JMeter,还支持更多工具,而且并非所有工具都可以存储请求和响应数据,因此我能想到的选项位于:

  1. 在测试计划中添加Listener,然后选择需要存储在单独文件中的指标,最容易使用的指标是Flexible File Writer
  2. 使用ShellExec Service从Taurus config YAML运行m2u.jar

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...