使用Ant运行JMeter 3.0测试时生成错误报告

时间:2016-07-29 09:13:32

标签: html ant jmeter

我已经好几天了。基本上我想使用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 report

如果有人能至少告诉我我应该去的错误或方向,我会非常感激。

2 个答案:

答案 0 :(得分:0)

看起来JMeter开发人员打破了jmeter-results-detail-report.xsl文件,此处报告了错误:

要恢复到以前的行为,请执行以下步骤:

  1. 下载apache-jmeter-2.13.zip
  2. jmeter-results-detail-report_21.xsl文件夹中提取apache-jmeter-2.13/extras文件并将其放到&#34; extras&#34; JMeter 3.0安装文件夹
  3. 修改您的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"/>
    
  4. 或者,您可以从here

    获取XSLT文件

    有关将JMeter XML结果文件转换为HTML格式的更多详细信息,请参阅Visualizing JMeter .jtl Files Viewed as An .xsl Stylesheet文章。

答案 1 :(得分:0)

这是我在这里报告的错误:

它将在下一个Apache JMeter 3.1或3.0.1中修复。

你可以通过在这里使用每晚构建来测试它是否正常:

为什么仍然使用Ant + xslt生成报告,而从3.0开始,您有一个新的Web报告,其中包含大量具有重要指标的动态图表和表格。

见: