简体   繁体   English

如何在带有响应正文的 jmeter 中生成 html 报告

[英]How can i generate html report in jmeter with response body

I have made these settings in my jmeter.properties file to save my response data when there is a failure我在 jmeter.properties 文件中进行了这些设置,以便在出现故障时保存响应数据

jmeter.save.saveservice.output_format=xml

#jmeter.save.saveservice.response_data=false

jmeter.save.saveservice.response_data.on_error=true

So with these settings i was able to save the responses and view them using jtl file after i run the script from non gui But the problem is with this setting jmeter.save.saveservice.output_format=xml i am unable to generate html report I wanted to generate html report with response body..can someone please help me out因此,通过这些设置,我能够保存响应并在我从非 gui 运行脚本后使用 jtl 文件查看它们但问题在于此设置 jmeter.save.saveservice.output_format=xml 我无法生成我想要的 html 报告生成带有响应正文的html报告..有人可以帮我吗

As of JMeter 5.3 you cannot generate HTML reporting dashboard from .jtl files in XML format, according to the documentation: 根据文档,从JMeter 5.3 开始,您无法从 XML 格式的 .jtl 文件生成 HTML 报告仪表板

The dashboard generator is a modular extension of JMeter.仪表板生成器是 JMeter 的模块化扩展。 Its default behavior is to read and process samples from CSV files to generate HTML files containing graph views.它的默认行为是从 CSV 文件读取和处理样本以生成包含图形视图的 HTML 文件。 It can generate the report at end of a load test or on demand.它可以在负载测试结束时或按需生成报告。

The easiest way of getting the response data into the HTML reporting dashboard is artificially failing the sampler(s) via JSR223 Assertion and setting assertion failure message to be current sampler's response data, example code:将响应数据放入 HTML 报告仪表板的最简单方法是通过JSR223 断言人为地使采样器失败,并将断言失败消息设置为当前采样器的响应数据,示例代码:

AssertionResult.setFailure(true)
AssertionResult.setFailureMessage(prev.getResponseDataAsString())

You will be able to get something like:你将能够得到类似的东西:

在此处输入图片说明

If this solution is not acceptable you can amend the report-template to represent whatever you want (the knowledge of Java and Freemarker will be required)如果此解决方案不可接受,您可以修改报告模板以表示您想要的任何内容(需要 Java 和Freemarker的知识)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM