Install Jmeter
Install Ant-Jmeter
Download the ant-jmeter jar here: http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php
The jar should be put in the ant\lib directory, for example here: <path>\apache-ant-1.8.1\lib\ant-jmeter-1.1.1.jar
Integrate Ant-Jmeter with Build system
Upload jars needed to create meter java requests
The ApacheJMeter_core.jar and ApacheJMeter_java.jar libraries in jmeter\lib\ext are needed to write jmeter java request classes, so they need to be visible.
- \ApacheJMeter_core-1.0.jar
- ApacheJMeter_java-1.0.jar
Create A JMeter Plan
Integrate Jmeter into Build project
Add a jmeter-run ant target to ant build.xml. Also copy the jmeter plan file to the output directory
<?xml version="1.0" encoding="UTF-8"?> <project name="test.JmeterTest" default="build"> <target name="copy-jmeter-plan"> <!-- copy jmeter plan file --> <copy todir="${output.root}"> <fileset dir="${project.root}" includes="*.jmx"/> </copy> <!-- make out directory --> <mkdir dir="${output.root}/out" /> </target> <!-- define jmeter task --> <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/> <target name="jmeter-run"> <jmeter jmeterhome="c:\dev\jmeter\apache-jmeter-2.6" testplan="${output.root}\CaptureJSONRequest.jmx" resultlog="${output.root}\out\CaptureJSONRequest.jtl"> <property name="user.classpath" value="${output.root}\lib\ApacheJMeter_core-1.0;${output.root}\lib\ApacheJMeter_java-1.0"/> </jmeter> <xslt in="${output.root}\out\CaptureJSONRequest.jtl" out="${output.root}\out\jmeter-results-report.html" style="C:\dev\jmeter\apache-jmeter-2.6\extras\jmeter-results-report_21.xsl"/> </target> </project>
Create a Jmeter Request Class
Add Jmeter Request to jmeter plan
Jmeter should display the newly added JavaRequestTest class.
Configure output file locations
Make file locations relative to location of plan, which is in the output.root based on build file copy-support. Specify file location for summary report as something like this: ~/out/summary-report.xml
Run Jmeter
Look at report
Look at the ant report:
Thanks for a brilliant example!
ReplyDelete//Mike