vlambda博客
学习文章列表

5步完成Jmeter可视化html报告的相关配置及实现!

点击蓝字关注我们

  今天我们来聊聊关于jmeter可视化html报告的相关配置及实现需要哪几步?

  1、jmeter请求的返回数据乱码问题

  在jmeter\bin\jmeter.properties文件下把sampleresult.default.encoding的属性改成UTF-8并解开注释。

  2、配置可视化报告的相关设置这个配置是在jmeter\bin\user.properties文件下

  在user.properties下找到下面没有#号的选项,并删除#号。

# Reporting configuration#---------------------------------------------# 

If you want to debug reporting, uncomment this line

log_level.jmeter.report=DEBUG

# Configure this property to change the report title

jmeter.reportgenerator.report_title=Apache JMeter Dashboard

# Change this parameter if you want to change the granularity of over time graphs.jmeter.reportgenerator.overall_granularity=60000

# Change this parameter if you want to change the granularity of Response time distribution

# Set to 500 ms by defaultjmeter.reportgenerator.graph.responseTimeDistribution.property.set_granularity=500

# Change this parameter if you want to keep only some samples.# Regular Expression which Indicates which samples to keep for graphs and statistics generation.

# Empty value means no filteringjmeter.reportgenerator.sample_filter=

# Change this parameter if you want to override the APDEX satisfaction threshold.jmeter.reportgenerator.apdex_satisfied_threshold=500

# Change this parameter if you want to override the APDEX tolerance threshold.jmeter.reportgenerator.apdex_tolerated_threshold=1500

# Indicates which graph series are filtered (regular expression)

# In the below example we filter on Search and Order samples

# Note that the end of the pattern should always include (-success|-failure)?

# TransactionsPerSecondGraphConsumer suffixes transactions with "-success" or "-failure" depending# on the result

#jmeter.reportgenerator.exporter.html.series_filter=(Search|Order)(-success|-failure)?

# Indicates whether only controller samples are displayed on graphs that support it.jmeter.reportgenerator.exporter.html.show_controllers_only=falsejmeter.reportgenerator.exporter.html.property.output_dir=C:\Users\cloudist\Downloads\apache-jmeter-3.0\apache-jmeter-3.0\bin\temp

  最后output_dir的指向路径根据自己的jmeter文件指向一般设置成/tem/test-report不过在使用命令生成可是话报告时的-o命定会覆盖这个设置你最后使用命令的指向是哪里可视化报告就会生成在那个文件夹下。

  3、在jmeter\bin\jmeter.properties文件下进行如下配置在jmeter\bin\jmeter.properties文件下找到下面没有#号的选项,将#号删除。

#---------------------------------------------------------------------------# 

Results file configuration

#---------------------------------------------------------------------------# 

This section helps determine how result data will be saved.

# The commented out values are the defaults.

# legitimate values: xml, csv, db.  Only xml and csv are currently supported.

#jmeter.save.saveservice.output_format=csv

# true when field should be saved; false otherwise

# assertion_results_failure_message only affects CSV outputjmeter.save.saveservice.assertion_results_failure_message=true

#

# legitimate values: none, first, all

#jmeter.save.saveservice.assertion_results=none

#

#jmeter.save.saveservice.data_type=truejmeter.save.saveservice.label=truejmeter.save.saveservice.response_code=true# response_data is not currently supported for CSV output

#jmeter.save.saveservice.response_data=false

# Save ResponseData for failed samplesjmeter.save.saveservice.response_data.on_error=truejmeter.save.saveservice.response_message=truejmeter.save.saveservice.successful=truejmeter.save.saveservice.thread_name=truejmeter.save.saveservice.time=true

#jmeter.save.saveservice.subresults=true

#jmeter.save.saveservice.assertions=truejmeter.save.saveservice.latency=true

#jmeter.save.saveservice.connect_time=false

#jmeter.save.saveservice.samplerData=false

#jmeter.save.saveservice.responseHeaders=false

#jmeter.save.saveservice.requestHeaders=false

#jmeter.save.saveservice.encoding=falsejmeter.save.saveservice.bytes=true

#jmeter.save.saveservice.url=false

#jmeter.save.saveservice.filename=false

#jmeter.save.saveservice.hostname=falsejmeter.save.saveservice.thread_counts=true

#jmeter.save.saveservice.sample_count=false

#jmeter.save.saveservice.idle_time=true

# Timestamp format - this only affects CSV output files

# legitimate values: none, ms, or a format suitable for SimpleDateFormatjmeter.save.saveservice.timestamp_format=msjmeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss

  这里的配置是保证输出的CSV文件具备转化成可视化报告的必备信息。

  4、在进行完上述两个文件的配置后,重新运行jmeter,在cmd中切换到jmeter的bin目录下执行以下命令jmeter -n -t要执行的脚本文件的路径-l生成报告文件的路径-e -o可视化报告的生成路径例:jmeter -n -t C:jmeter\test.jmx -l C:desktop\result -e -o C:desktop\report这里的result可以是存在文件也可以是不存在的文件report文件必须是不存在的,否则的会执行失败用已经生成好的jtl或者csv文件转化成可视化报告jmeter -g生成好的jtl或者CSV文件的路径-o可视化报告的路径例:jmeter -g C:jmeter\test.csv -o C:desktop\report同理,report文件必须不存在。

   5、关于生成的可视化报告的乱码问题的解决这个是在jmeter源码中的中文处理上的编码错误将jmeter\lib\ext中的ApacheJMeter_core.jar文件替换成下面的文件,从新运行即可这个问题主要出现在3.0及之前版本上,3.0之后没有这个问题。

扫描二维码关注我们