Go: Batch execute jmeter script via Ant and Generate report (attached: Generate report times "Content is not allowed in Prolog" solution for this error)

Source: Internet
Author: User
Tags xslt

Recently in the use of JMeter write scripts to test, eventually wrote a lot of scripts, and then, just think, so many scripts, I can not one of the manual to point Ah, there is no way to run the JMeter script in bulk?

This time, naturally think of the Almighty ant, hope it can have a corresponding JMeter task.

Ah, ah, check a bit, there is really, cool crooked ah.

Here's a quick explanation, if you use:

① first, in order to be able to use JMeter task in Ant, the "Ant-jmeter-1.1.1.jar" jar package must be placed in Ant's classpath. This jar package is located in the Extras directory under the JMeter installation directory.

PS: You can copy this jar directly to the Lib directory in the ant installation directory.

② Writing scripts

Ant Code
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="ant-jmeter-test" default="all" basedir="." >
  3. <tstamp>
  4. <format property= "Time" pattern="yyyymmddhhmm"/>
  5. </tstamp>
  6. <!--need to change to their local Jmeter directory--
  7. <property name="jmeter.home" value="F:\xxxxx\Jmeter"/>
  8. <!--jmeter Generate JTL Format Results report path--
  9. <property name="Jmeter.result.jtl.dir" value="F:\xxxxx\resultLog\jtl"/>
  10. <!--JMeter generates a path to the results report in HTML format--
  11. <property name="Jmeter.result.html.dir" value="F:\xxxxx\resultLog\html"/>
  12. < prefix for reports generated by!--
  13. <property name="ReportName" value="Testreport"/>
  14. <property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${reportname}${time}.jtl"/>
  15. <property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${reportname}${time}.html"/ >
  16. <target name="All" >
  17. <antcall target="test"/>
  18. <antcall target="Report"/>
  19. </target>
  20. <target name="Test" >
  21. <taskdef name="JMeter" classname="Org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
  22. <jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlname}" >
  23. <!--declare the script to run. "*.jmx" means all JMeter scripts that contain this directory--
  24. <testplans dir="D:\test_case_path" includes="*.jmx"/>
  25. </jmeter>
  26. </target>
  27. <target name="Report" >
  28. <xslt in="${jmeter.result.jtlname}"
  29. out="${jmeter.result.htmlname}"
  30. style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl"/>
  31. <!--because when the report is generated, the associated pictures are not copied to the target directory, so you need to manually copy--
  32. <copy todir="${jmeter.result.html.dir}" >
  33. <fileset dir="${jmeter.home}/extras" >
  34. <include name="Collapse.png"/>
  35. <include name="Expand.png"/>
  36. </fileset>
  37. </copy>
  38. </target>
  39. </project>

③ generated results reports such as



④ Here is a question I encountered in the process of using: The following error has been reported when executing the task that generated the report last:

Transformerexception, Content is not allowed in Prolog.

Later on the Ant-jmeter official online found the reason:

Java code
    1. Note:as of JMeter 1.9rc2 (?), the default results output format is now CSV. It must is changed to XML in order to use the XSLT task to create the HTML report:

So we need to modify a configuration of JMeter

Java code
    1. Jmeter.save.saveservice.output_format=xml

And then you can generate the report normally.

Attached: Ant-jmeter official website: http://www.programmerplanet.org/projects/jmeter-ant-task/

Go: Batch execute jmeter script via Ant and Generate report (attached: Generate report times "Content is not allowed in Prolog" solution for this error)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.