在开始通过ANT运行build.xml之前,有一步必须要做,那就是将JMeter所在目录下extras子目录里的ant-JMeter-1.1.1.jar复制到Ant所在目录lib子目录之下,这样Ant运行时才能找到"org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"这个类,从而成功触发JMeter脚本
<?xmlversion="1.0"?>
<projectname="autotest" default="all" basedir=".">
<propertyname="JMeter.home" value="......."/>
<propertyname="mail_to" value="Bodhi.Zhang@example.com,lucy.chen@example.com"/>
<propertyname="ReportName" value="SnoopyAutoTestReport"/>
<propertyname="ComputerName" value="szpc8888"/>
<tstamp>
<formatproperty="time" pattern="yyyyMMddhhmm"/>
</tstamp>
<targetname="all" >
<antcalltarget="runBasicData"/>
<antcalltarget="runDeleteBasicData"/>
<antcalltarget="transfer"/>
<antcalltarget="sendEmail"/>
</target>
<targetname="runBasicData" depends="">
<taskdefname="jmeter"classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
<jmeterjmeterhome="${JMeter.home}"resultlog="${basedir}/Result/${ReportName}${time}.jtl">
<testplansdir="${basedir}ScriptSmokeTest"includes="CIM_NewBasicData_SmokeTest_TP.jmx"/>
</jmeter>
</target>
<targetname="runDeleteBasicData" depends="">
<taskdefname="jmeter"classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
<jmeterjmeterhome="${JMeter.home}"resultlog="${basedir}/Result/${ReportName}${time}.jtl">
<testplansdir="${basedir}ScriptSmokeTest"includes="CIM_DeleteBasicData_SmokeTest_TP.jmx"/>
</jmeter>
</target>
<targetname = "transfer" depends = "">
<xsltin="${basedir}/Result/${ReportName}${time}.jtl"
out="${JMeter.home}/extras/${ReportName}${time}.html"
style="${JMeter.home}/extras/JMeter-results-detail-report_21.xsl"/>
</target>
<targetname="sendEmail">
<mailmailhost="internalmail.example.com" mailport="25"subject="SmokeTest Report!" messagemimetype="text/html"tolist="${mail_to}">
<fromaddress="jenny.zhang@example.com"/>
<!--filesetdir="${JMeter.home}/extras/">
<includename="${ReportName}${time}.html"/>
</fileset-->
<message>Thisemail was sent automatically by ANT. <br />
Pleasecheck the automation test report by the link below. <br />
Ifthere are any questions, please contact with Bodhi Zhang. Thank you!<br /><br />
http://${ComputerName}/${ReportName}${time}.html
</message>
</mail>
</target>
</project>
源文档 <http://www.cnblogs.com/MasterMonkInTemple/archive/2013/08/29/3289321.html>