如何在 JMeter 的摘要报告和 HTML 仪表板报告中显示请求数据

How to show Request data in Summary report and HTML dashboard report in JMeter

我想在摘要报告和 HTML 仪表板报告中显示在 post API 中传递的请求数据。对于例如。如果登录 API 被点击然后 baseURL/api/auth/users/login 输入数据:{“电子邮件”:“abc@gmail.com”,“密码”:“Abc123”} 我需要在摘要报告和 HTML 仪表板报告中显示 { "Email" : "abc@gmail.com", "Password" : "Abc123"} 此数据。

根据JMeter 5.4.1 it's not very possible without massive changes to JMeter Source code

此外,我怀疑该功能是否会实现,因为您应该 reduce resource requirements to the absolute minimum

如果出于某种原因您仍然需要在报告中的某处获取请求数据信息,我能想到的唯一选择是将请求数据添加到 Sampler 标签中,例如:

  1. 添加JSR223 PostProcessor as a child of the request which data you need to store (or if you want to store the data for all Samplers - put the JSR223 PostProcessor at the same level with the Samplers, see JMeter Scoping Rules - The Ultimate Guide了解更多详情)

  2. 将以下代码放入“脚本”区域:

    prev.setSampleLabel(prev.getSampleLabel() + ': ' + prev.getSamplerData())
    

这就是您将在 Summary Report 侦听器中获得的内容:

这就是 HTML Reporting Dashboard 的样子: