1 <?xml version="1.0" encoding="UTF-8"?> 2 <project name="JmeterTest" default="all" basedir="."> 3 <tstamp> 4 <format property="time" pattern="yyyy/MM/dd HH:mm" /> 5 </tstamp> 6 7 <!--Jmeter主目录--> 8 <property name="jmeter.home" value="D:/ProgramFiles/apache-jmeter-3.1" /> 9 10 11 <!--存放Jmeter生成的报告文件的文件夹--> 12 <property name="jmeter.result.dir" value="D:/ProgramFiles/jenkinsworkspace/workspace/Jmeter/results" /> 13 14 <!--Jmeter文件名--> 15 <property name="ReportName" value="TestReport" /> 16 17 <!--jtl文件--> 18 <property name="jmeter.result.jtlName" value="${jmeter.result.dir}/${ReportName}.jtl" /> 19 <!--html报告文件--> 20 <property name="jmeter.result.htmlName" value="${jmeter.result.dir}/${ReportName}.html" /> 21 22 23 <!--汇总标签--> 24 <target name="all"> 25 <antcall target="clean" /> 26 <antcall target="test" /> 27 <antcall target="report" /> 28 </target> 29 30 <!--每次清除Jmeter生成的结果目录--> 31 <target name="clean"> 32 <delete includeemptydirs="true"> 33 <fileset dir="${jmeter.result.dir}" includes="**/*"/> 34 </delete> 35 </target> 36 37 38 <!--运行Jmeter脚本文件--> 39 <target name="test"> 40 <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" /> 41 <jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}"> 42 <testplans dir="D:/jmeter/script" includes="*.jmx" /> 43 <property name="jmeter.save.saveservice.output_format" value="xml"/> 44 </jmeter> 45 </target> 46 47 <path id="xslt.classpath"> 48 <fileset dir="${jmeter.home}/lib" includes="xalan*.jar"/> 49 <fileset dir="${jmeter.home}/lib" includes="serializer*.jar"/> 50 </path> 51 52 <!--生成测试报告--> 53 <target name="report"> 54 <xslt classpathref="xslt.classpath" force="true" in="${jmeter.result.jtlName}" ut="${jmeter.result.htmlName}" style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl" > 55 <param name="dateReport" expression="${time}"/> 56 </xslt> 57 <!--复制报告所需图标--> 58 <copy todir="${jmeter.result.dir}"> 59 <fileset dir="${jmeter.home}/extras"> 60 <include name="collapse.png" /> 61 <include name="expand.png" /> 62 </fileset> 63 </copy> 64 </target> 65 66 </project> |