One of the interface Automation tests using jmeter+ant (Data driven) Describes how to use a CSV file to manage interfaces in bulk
This article then describes how to use Apache-ant to execute test Cases and generate HTML format test reports
① downloading and installing apache-ant-1.9.9, configuring environment variables
Verify installation success as follows
② after installing ant, copy the Ant-jmeter-1.1.1.jar file from the Extras directory in JMeter to the Lib folder in the Ant installation directory
③ Configuring the Ant compilation file build.xml
Create a new TXT file and rename it as Build.xml with the following content
1 <?XML version= "1.0" encoding= "UTF-8"?>2 <Projectname= "Ant-jmeter-test"default= "Run"Basedir=".">3 <Tstamp>4 <format Property= "Time"pattern= "YYYYMMDDHHMM" />5 </Tstamp>6 <!--need to change to your local Jmeter directory -7 < Propertyname= "Jmeter.home"value= "D:\worksoft\apache-jmeter-3.1" />8 <!--JMeter Generating the path of the result report in JTL format -9 < Propertyname= "Jmeter.result.jtl.dir"value= "D:\worksoft\apache-jmeter-3.1\bin\commonservice\smoke_report" />Ten <!--JMeter Generating the path of the result report in HTML format - One < Propertyname= "Jmeter.result.html.dir"value= "D:\worksoft\apache-jmeter-3.1\bin\commonservice\smoke_report" /> A <!--The prefix of the generated report - - < Propertyname= "ReportName"value= "Testreport" /> - < Propertyname= "Jmeter.result.jtlName"value= "${JMETER.RESULT.JTL.DIR}/${REPORTNAME}${TIME}.JTL" /> the < Propertyname= "Jmeter.result.htmlName"value= "${jmeter.result.html.dir}/${reportname}.html" /> - <Targetname= "Run"> - <AntcallTarget= "Test" /> - <AntcallTarget= "Report" /> + </Target> - <Targetname= "Test"> + <Taskdefname= "JMeter"ClassName= "Org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" /> A <JMeterJmeterhome= "${jmeter.home}"Resultlog= "${jmeter.result.jtlname}"> at <!--declares the script to run. "*.jmx" means all JMeter scripts that contain this directory - - <Testplansdir= "D:\worksoft\apache-jmeter-3.1\bin\commonservice\"includes= "Unified bid interface. JMX" /> - - < Propertyname= "Jmeter.save.saveservice.output_format"value= "xml"/> - </JMeter> - </Target> in - <PathID= "Xslt.classpath"> to <Filesetdir= "${jmeter.home}/lib"includes= "Xalan*.jar"/> + <Filesetdir= "${jmeter.home}/lib"includes= "Serializer*.jar"/> - </Path> the * <Targetname= "Report"> $ <Tstamp> <format Property= "Report.datestamp"pattern= "Yyyy/mm/dd hh:mm" /></Tstamp>Panax Notoginseng <XSLT - Classpathref= "Xslt.classpath" the Force= "true" + A inch= "${jmeter.result.jtlname}" the out= "${jmeter.result.htmlname}" + style= "${jmeter.home}/extras/jmeter.results.shanhe.me.xsl" /> - $ <!--because the report is generated above, the related pictures will not be copied to the target directory, so we need to copy them manually . - $ <CopyTodir= "${jmeter.result.html.dir}"> - <Filesetdir= "${jmeter.home}/extras"> - <includename= "Collapse.png" /> the <includename= "Expand.png" /> - </Fileset>Wuyi </Copy> the </Target> - </Project>
Modify the Build.xml file according to the actual situation
④ Configuration jmeter.properties
Configure The jmeter report output format as XML, in the JMeter bin directory jmeter.properties File, modify jmeter.save.saveservice.output_format=csv to Jmeter.save.saveservice.output_format=xml, and remove the previous comment symbol #
⑤ put jmeter scripts, build.xml files, and test data in the same folder to perform the test
Switch to the JMeter script store path in the Command Line window, enter Ant run, perform the test
Review the test report after the execution is complete, as shown below, using the report template that comes with JMeter
⑥ Test Report further optimization
Download Optimization template jmeter.results.shanhe.me.xsl, copy to JMeter Extras directory
then in jmeter.properties, set the content that needs to be output to true, and remove the previous comment symbol #, all set to true
set The report template for the build file to the optimized template
Perform the test again with ant to see the optimized test report
Attached: jmeter.results.shanhe.me.xsl download link https://pan.baidu.com/s/1eTki1KQ password: JSUW
Interface Automation testing using jmeter+ant (Data driven) bis: Execute test Cases with apache-ant and generate HTML format test reports