我已经做了好几天了。基本上,我想使用Ant从JMeter测试文件创建一个HTML报告。我使用的是Linux Ubuntu 16.04.1。这是我的build.xml:
<project name="performance-tests" default="run-performance-tests" basedir=".">
<property name="testpath" value="${user.dir}"/>
<poperty name="jmeter.home" value="/home/richard/Asjad/apache-jmeter-3.0"/>
<!-- Name of test (without .jmx) -->
<property name="test" value="Test"/>
<path id="jmeter.path">
<fileset dir="${basedir}" includes="/*.jar" />
</path>
<target name="run-performance-tests">
<delete dir="${basedir}/target" quiet="true" failonerror="false"/>
<mkdir dir="${basedir}/target"/>
<!-- Allow jar to be picked up locally -->
<path id="jmeter.classpath">
<fileset dir="${basedir}">
<include name="ant-jmeter*.jar"/>
</fileset>
</path>
<taskdef name="jmeter"
classpathref="jmeter.classpath"
classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
<echo message="Running load tests in testing.xml"/>
<jmeter
jmeterhome="${jmeter.home}"
testplan ="${testpath}/${test}.jmx"
resultlog="${basedir}/target/JMeterResults.xml">
<jvmarg value="-Xincgc"/>
<jvmarg value="-Xmx512m"/>
<jvmarg value="-Dproperty=value"/>
<property name="request.threads" value="5"/>
<property name="request.loop" value="50"/>
<property name="jmeter.save.saveservice.assertion_results" value="all"/>
<property name="jmeter.save.saveservice.output_format" value="xml"/>
</jmeter>
<xslt in="${basedir}/target/JMeterResults.xml"
out="${basedir}/target/Test.html"
style="${basedir}/jmeter-results-detail-report.xsl"/>
</target>
这是我运行脚本时看到的:
Buildfile: /home/richard/Asjad/apache-jmeter-3.0/extras/build.xml
run-performance-tests:
[delete] Deleting directory /home/richard/Asjad/apache-jmeter-3.0/extras/target
[mkdir] Created dir: /home/richard/Asjad/apache-jmeter-3.0/extras/target
[echo] Running load tests in testing.xml
[jmeter] Executing test plan: /home/richard/Asjad/apache-jmeter-3.0/extras/TestPlan/Test.jmx ==> /home/richard/Asjad/apache-jmeter-3.0/extras/target/JMeterResults.xml
[jmeter] Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
[jmeter] Writing log file to: /home/richard/Asjad/apache-jmeter-3.0/bin/jmeter.log
[jmeter] Creating summariser <summary>
[jmeter] Created the tree successfully using /home/richard/Asjad/apache-jmeter-3.0/extras/TestPlan/Test.jmx
[jmeter] Starting the test @ Fri Jul 29 11:57:25 EEST 2016 (1469782645099)
[jmeter] Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
[jmeter] summary = 10 in 00:00:02 = 4.6/s Avg: 214 Min: 105 Max: 344 Err: 0 (0.00%)
[jmeter] Tidying up ... @ Fri Jul 29 11:57:27 EEST 2016 (1469782647345)
[jmeter] ... end of run
[xslt] Processing /home/richard/Asjad/apache-jmeter-3.0/extras/target/JMeterResults.xml to /home/richard/Asjad/apache-jmeter-3.0/extras/target/Result_One.html
[xslt] Loading stylesheet /home/richard/Asjad/apache-jmeter-3.0/extras/jmeter-results-detail-report.xsl
BUILD SUCCESSFUL
Total time: 3 seconds
构建成功,然后它给了我一个HTML文件,当我打开它时,我会看到:HTML报告
如果有人能告诉我我的错误或我应该走的方向,我会非常感激。
看起来JMeter开发人员破坏了jmeter-results-detail-report.xsl
文件,这里报告了错误:
- https://bz.apache.org/bugzilla/show_bug.cgi?id=59918它将在下一个ApacheJMeter 3.1版本中得到修复
为了恢复到以前的行为,请采取以下步骤:
- 下载apache-jmeter-2.13.zip
- 从
apache-jmeter-2.13/extras
文件夹中提取jmeter-results-detail-report_21.xsl
文件,并将其放到JMeter 3.0安装的"extrass"文件夹中 -
修改您的
build.xml
文件以使用jmeter-results-detail-report_21.xsl
文件,如:<xslt in="${basedir}/target/JMeterResults.xml" out="${basedir}/target/Test.html" style="${basedir}/jmeter-results-detail-report_21.xsl"/>
或者,您可以从这里获得XSLT文件,即
有关将JMeter XML结果文件转换为HTML格式的更多详细信息,请参阅可视化作为.xsl样式表查看的JMeter.jtl文件。
我在这里报告了一个错误:
- https://bz.apache.org/bugzilla/show_bug.cgi?id=59918
它将在下一个ApacheJMeter 3.1或3.0.1版本中修复。
你可以使用这里的夜间构建来测试它是否可以:
- http://jmeter.apache.org/nightly.html
为什么仍然使用Ant+xslt来生成报告,而自3.0以来,您有了一个新的web报告,其中包含许多动态图表和具有重要指标的表。
参见:
- https://jmeter.apache.org/usermanual/generating-dashboard.html