First, the basic set up of environmental requirements:
1, JDK (I use version: java version "1.8.0_152")
2, Jmeter installation and configuration environment variable (using Version: 5.1.1 r1855137)
3, Ant and the installation environment variable configuration (version: Apache Ant (TM) version 1.10.6 compiled on May 2 2019)
The above steps are omitted, please refer to other tutorials
Two, Jmeter + Ant integration steps
1, the directory extras jmeter the ant-jmeter-1.1.1.jar packet copy to the ant lib installation directory under the directory
2, jmeter test script on a directory (such as :)
3, modify jmeter directory: apache-jmeter-3.1 \ extras are copied down to the build.xml and script files in the same directory (with reference to the screenshots, modify according to their own directory)
<?xml version="1.0" encoding="UTF-8"?> <project name="ant-jmeter-test" default="run" basedir="."> <tstamp> <format property="time" pattern="yyyyMMddhhmm" /> </tstamp> <!-- 需要改成自己本地的 Jmeter 目录--> <property name="jmeter.home" value="D:\Program Files\apache-jmeter-5.1.1" /> <!- nameProperty<->JMeter jtl result report format generating path = "jmeter.result.jtl.dir" value = "D: \ test_jmeter \ reoprt \ JTL" /> ! <- JMeter result report generated html format Path -> < Property name = "jmeter.result.html .dir " value =" D: \ test_jmeter \ reoprt \ HTML " /> <-! prefix report generated -> < Property name =" the ReportName " value =" the TestReport " /> < Property name =" JMeter. result.jtlName " value =" $ {jmeter.result.jtl.dir} / {the 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}"> <!--To run the script statement. "* .jmx" refers to all jmeter script contains this directory in the -> < testplans dir = "D: \ test_jmeter" Includes =. "* JMX" /> < Property name = "jmeter.save.saveservice.output_format" value = "XML" /> </ JMeter > </ target > < path ID = "xslt.classpath" > < fileset the dir = "$ {jmeter.home} / lib" Includes = "Xalan * .jar" /> < fileset the dir = "$ {JMeter. </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 The = "$ {report.datestamp}" /> </ XSLT > <-! because when generating reports above the associated picture will not be copied to the target directory together, therefore, need to manually copy - -> < Copy todir = "$ {} jmeter.result.html.dir" > < fileset the dir = "$ {} jmeter.home / Extras" > < the include name = "collapse.png" /> < the include name = " expand.png " /> </ fileset > </ Copy > </ target > </project>
4, cmd enter the directory where the script, direct the implementation of "ant" can (As online resources is uneven, partly under their own needs confirmation)
5, the script (just had a jmeter own handwriting script) after a successful run, can enter the directory again to see the results report
6, the basic environment ok, you can continue to learn behind a ~
7, recording errors, copy the xml file is not recommended to use a direct copy