### JMeter Ant Task

This is an Ant task for automating running JMeter test plans. The task executes one or more JMeter test plans, and logs the results to a file.

To use the task, you must have JMeter installed. You must also include ant-jmeter.jar in your Ant classpath. Adding the jar to $ANT_HOME/lib will make this happen automatically.

Start by defining the task to make it available to your build script:

    <taskdef
        name="jmeter"
        classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>

Set the jmeterhome parameter to your JMeter install location, and the resultlog parameter to the name of a file to log the test results to.

You can either specify a single test plan using the testplan parameter, or multiple test plans using the testplans nested element. The testplans element is a standard Ant FileSet element.

    <jmeter
        jmeterhome="c:\jakarta-jmeter-1.8.1"
        testplan="${basedir}/loadtests/JMeterLoadTest.jmx"
        resultlog="${basedir}/loadtests/JMeterResults.jtl"/>

    <jmeter
        jmeterhome="c:\jakarta-jmeter-1.8.1"
        resultlog="${basedir}/loadtests/JMeterResults.jtl">
    	<testplans dir="${basedir}/loadtests" includes="*.jmx"/>
    </jmeter>

You may also specify additional JVM arguments to the JVM launched to run JMeter. Here is an example of how to specify JVM arguments:

    <jmeter
        jmeterhome="c:\jakarta-jmeter-1.8.1"
        testplan="${basedir}/loadtests/JMeterLoadTest.jmx"
        resultlog="${basedir}/loadtests/JMeterResults.jtl">
    	<jvmarg value="-Xincgc"/>
    	<jvmarg value="-Xmx128m"/>
    	<jvmarg value="-Dproperty=value"/>
    </jmeter>

I've also included an XSLT file, jmeter-results-report.xsl, for generating a summary report from the result log file. The summary report is very similar to the default report created by the junitreport task. You can use the xslt task to create the report:

    <xslt
        in="${basedir}/loadtests/JMeterResults.jtl"
        out="${basedir}/loadtests/JMeterResults.html"
        style="${basedir}/loadtests/jmeter-results-report.xsl"/>

If you would like failure detail messages in the report output, you must configure JMeter to output that information to the result log. To do this, set the following property in your jmeter.properties file before running the test plans:

    jmeter.save.saveservice.assertion_results=all

Note: As of JMeter 1.9RC2(?), the default results output format is now csv. It must be changed to xml in order to use the xslt task to create the html report:

    jmeter.save.saveservice.output_format=xml

The report will look something like this:

There is also another XSLT file available which generates an enhanced report that includes expandable details. jmeter-results-detail-report.zip contains the XSLT file and images. Note: This report has not been tested on all browsers.

jfifield@programmerplanet.org
Last updated: 7/29/2003