Ant
: http://archive.apache.org/dist/ant/binaries/
Download: Apache-ant-1.9.7-bin.zip
Unzip to system tray: D:\apache-ant-1.9.7-bin\apache-ant-1.9.7
Configuring the ANT environment variable
environment variable settings in window:
Path:d:\apache-ant-1.9.7-bin\apache-ant-1.9.7\bin
Verify ant:cmd command-line input: ant–version
C:\users\sfit1175>ant-version
Apache Ant (TM) version 1.9.7 compiled on April 9 2016
Success
JMeter (version 2.11)
1. Copy the Ant-jmeter-1.1.1.jar package from the JMeter Extras directory to the Lib directory in the ant installation directory
2, modify the JMeter bin directory under the jmeter.properties file configuration:
Jmeter.save.saveservice.output_format=xml
3. JMeter set the script and save it (my script directory: D:\apache-jmeter-2.11\demo)
Create a Build.xml configuration file
Build.xml file directory, placed in the same directory as the. JMX Script
Build.xml Code:
<?xml version= "1.0" encoding= "UTF-8"?>
<project name= "Ant-jmeter-test" default= "Run" basedir= "." >
<tstamp>
<format property= "Time" pattern= "Yyyymmddhhmm"/>
</tstamp>
<!--need to change to their local Jmeter directory--
<property name= "Jmeter.home" value= "D:\apache-jmeter-2.11"/>
<!--jmeter Generate JTL Format Results report path--
<property name= "Jmeter.result.jtl.dir" value= "D:\apache-jmeter-2.11\demo\report\jtl"/>
<!--JMeter generates a path to the results report in HTML format--
<property name= "Jmeter.result.html.dir" value= "D:\apache-jmeter-2.11\demo\report\html"/>
<!--generated report prefixes--
<property name= "ReportName" value= "Testreport"/>
<property name= "Jmeter.result.jtlName" value= "${jmeter.result.jtl.dir}/${reportname}${time}.jtl"/>
<property name= "Jmeter.result.htmlName" value= "${jmeter.result.html.dir}/${reportname}${time}.html"/>
<target name= "Run" >
<antcall target= "Test"/>
<antcall target= "Report"/>
</target>
<target name= "Test" >
<taskdef name= "JMeter" classname= "Org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
<jmeter jmeterhome= "${jmeter.home}" resultlog= "${jmeter.result.jtlname}" >
<!--declare the script to run. "*.jmx" means all JMeter scripts that contain this directory--
<testplans dir= "D:\apache-jmeter-2.11\demo" includes= "*.jmx"/>
<property name= "Jmeter.save.saveservice.output_format" value= "xml"/>
</jmeter>
</target>
<path id= "Xslt.classpath" >
<fileset dir= "${jmeter.home}/lib" includes= "Xalan*.jar"/>
<fileset dir= "${jmeter.home}/lib" includes= "Serializer*.jar"/>
</path>
<target name= "Report" >
<tstamp> <format property= "Report.datestamp" pattern= "Yyyy/mm/dd hh:mm"/></tstamp>
<xslt
classpathref= "Xslt.classpath"
Force= "true"
In= "${jmeter.result.jtlname}"
out= "${jmeter.result.htmlname}"
style= "${jmeter.home}/extras/jmeter-results-detail-report_21.xsl" >
<param name= "Datereport" expression= "${report.datestamp}"/>
</xslt>
<!--because when the report is generated, the associated pictures are not copied to the target directory, so you need to manually copy--
<copy todir= "${jmeter.result.html.dir}" >
<fileset dir= "${jmeter.home}/extras" >
<include name= "Collapse.png"/>
<include name= "Expand.png"/>
</fileset>
</copy>
</target>
</project>
Ant Run Script:
1. cmd command line into the script directory
2. Execute the command: Ant or Ant run (Run is the task name in Build.xml) and execute the result:
D:\apache-jmeter-2.11\demo>ant
Buildfile:d:\apache-jmeter-2.11\demo\build.xml
Run
Test
[JMeter] Executing test plan:d:\apache-jmeter-2.11\demo\read.jmx ==> D:\apac
He-jmeter-2.11\demo\report\jtl\testreport201605190320.jtl
[JMeter] Creating summariser <summary>
[JMeter] Created the tree successfully using D:\apache-jmeter-2.11\demo\read.
Jmx
[JMeter] Starting the test @ Thu 15:20:30 CST 2016 (1463642430955)
[JMeter] Waiting for possible shutdown message on port 4445
[JMeter] Summary + 1 in 0.1s = 14.9/s avg:67 min:67 Max:
err:0 (0%) Active:6 Started:6 finished:0
[jmeter] summary + 1s = 125.5/s avg:53 min:12 max:1
err:0 (0%) active:0 started:10 Finished:10
[jmeter] summary = 1s = 126.7/s avg:53 min:12 max:1
err:0 (0%)
[JMeter] Tidying up ... @ Thu 15:20:33 CST 2016 (1463642433497)
[JMeter] ... end of run
Report
[XSLT] Processing D:\apache-jmeter-2.11\demo\report\jtl\TestReport201605190
320.JTL to D:\apache-jmeter-2.11\demo\report\html\TestReport201605190320.html
[XSLT] Loading stylesheet D:\apache-jmeter-2.11\extras\jmeter-results-detai
L-report_21.xsl
[Copy] Copying 2 files to D:\apache-jmeter-2.11\demo\report\html
BUILD Successful
Total Time:5 seconds
Test Report directory: D:\apache-jmeter-2.11\demo\report\html
Jenkins Integration
1. Install Jenkins Environment
A): https://jenkins.io/index.html
Jenkins.war
b) installation under Windows (JDK1.5 version or above)
Command line switch to Jenkins.war root directory, enter Java-jar Jenkins.war
Browser input address http://localhost:8080/display interface, installation successful
New Job
Jmeter+ant+jenkins Interface Automatic Environment construction