分享

New XSL stylesheet for JMeter command line results report | shanhe.me

 _bolo 2017-09-12

JMeter has built-in ant integration, which allows us to run JMeter from command line. The result of running from command line is a JTL output file. This file is actually an XML file, and can be converted to an HTML file for better readability using an XSL stylesheet. HTML files converted using the stylesheet provided here will look similar to

Fig. 1.  An example HTML file converted from a JTL file in IE9.

Installation:

  1. Edit extras/build.xml in the JMeter distribution, locate
    <!-- Force suitable defaults -->
    <property name="jmeter.save.saveservice.output_format" value="xml"/>
    <property name="jmeter.save.saveservice.assertion_results" value="all"/>
    <property name="jmeter.save.saveservice.bytes" value="true"/>
    <property name="file_format.testlog" value="${format}"/>
    <property name="jmeter.save.saveservice.response_data.on_error" value="${funcMode}"/>

    and add as much information as you want, such as

    <!-- Force suitable defaults -->
    <property name="jmeter.save.saveservice.response_data" value="true"/>
    <property name="jmeter.save.saveservice.samplerData" value="true"/>
    <property name="jmeter.save.saveservice.responseHeaders" value="true"/>
    <property name="jmeter.save.saveservice.requestHeaders" value="true"/>
    <property name="jmeter.save.saveservice.encoding" value="true"/>
    <property name="jmeter.save.saveservice.url" value="true"/>
    <property name="jmeter.save.saveservice.filename" value="true"/>
    <property name="jmeter.save.saveservice.hostname" value="true"/>
    <property name="jmeter.save.saveservice.thread_counts" value="true"/>
    <property name="jmeter.save.saveservice.sample_count" value="true"/>
    <property name="jmeter.save.saveservice.idle_time" value="true"/>
    <property name="jmeter.save.saveservice.output_format" value="xml"/>
    <property name="jmeter.save.saveservice.assertion_results" value="all"/>
    <property name="jmeter.save.saveservice.bytes" value="true"/>
    <property name="file_format.testlog" value="${format}"/>
    <property name="jmeter.save.saveservice.response_data.on_error" value="${funcMode}"/>

    so that what you see in the JMeter GUI will be shown in the HTML file. The property names were found in bin/jmeter.properties.

  2. Locate in extras/build.xml again for
    <target name="report" depends="_message_xalan">
      <xslt
        classpathref="xslt.classpath"
        force="true"
          in="${testpath}/${test}.jtl"
          out="${testpath}/${test}.html"
          style="${basedir}/jmeter-results-detail-report${style_version}.xsl">
        <param name="showData" ="${show-data}"/>
      </xslt>
    </target>

    Change the style attribute to look like

    <target name="report" depends="_message_xalan">
      <xslt
        classpathref="xslt.classpath"
        force="true"
          in="${testpath}/${test}.jtl"
          out="${testpath}/${test}.html"
          style="${basedir}/jmeter-results-shanhe-me.xsl">
        <param name="showData" ="${show-data}"/>
      </xslt>
    </target>
  3. Download jmeter-results-shanhe-me.xsl by following the links at the bottom of the page, and save the file to extras/jmeter-results-shanhe-me.xsl.
  4. From the Command Prompt, change the current working directory to the extras folder, e.g., "cd C:\jakarta-jmeter-2.4\extras", and execute "ant". This will run Test.jmx and get Test.html.
    Fig. 2.  Execute ant from the Command Prompt.
  5. You can also specify the path and the file name of the jmx file, e.g., you can run "ant -Dtest=Test -Dtestpath=C:\jakarta-jmeter-2.4\extras" to execute the same Test.jmx in the extras folder.
    Fig. 3.  Execute ant with the path and the file name specified from the Command Prompt.

The output HTML file is compatible with Ie8+/Opera/Firefox/Safari/Chrome.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多