Archive

Archive for the ‘Ant’ Category

Ant Task to run Jmeter test plan

December 14, 2009 Leave a comment

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.

You must include ant-jmeter-1.0.9.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 result-log 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>

Optional JMeter arguments supported include specifying an alternate jmeter properties file (jmeter.properties),

running remote servers specified in jmeter properties file (runremote),

and running the tests through a proxy or firewall (proxyhost, proxyport, proxyuser, proxypass).

Setting the failureProperty attribute will set the specified property to "true" in the event of a JMeter test failure.

<jmeter
jmeterhome="c:jakarta-jmeter-1.8.1"
testplan="${basedir}/loadtests/JMeterLoadTest.jmx"
resultlog="${basedir}/loadtests/JMeterResults.jtl">
<property name="request.threads" value="1"/>
<property name="request.loop" value="10"/>
</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>
Categories: Ant Tags: ,