jmter+ANT+jekins之配置文件简单优化(build.xml)
<?xml version="1.0" encoding="utf-8"?>
<project name="ant-jmeter-test" default="all" basedir=".">
<tstamp>
<format property="time" pattern="yyyyMMddhhmm" />
</tstamp>
<!-- 需要改成自己本地的 Jmeter 目录-->
<property name="jmeter.home" value="D:\jmeter3.3" />
<!-- 生的报成告的title名-->
<property name="report.title" value="jmeter-result"/>
<!-- jmeter生成jtl格式的结果报告的路径 "D:\jmeter3.3\newTest\report\jtl\"表示当前路径-->
<property name="jmeter.result.jtl.dir" value="D:\jmeter3.3\newTest\report\jtl" />
<!-- jmeter生成html格式的结果报告的路径 "D:\jmeter3.3\newTest\report\html\jmeter-result.html"标识当前路径-->
<property name="jmeter.result.html.dir" value="D:\jmeter3.3\newTest\report\html" />
<!-- jmeter生成csv格式的结果报告的路径-->
<property name="jmeter.result.csv.dir" value="${location}\report\csv" />
<!-- 生成的报告的前缀-->
<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" />
<property name="jmeter.result.csvName" value="${jmeter.result.csv.dir}/${ReportName}${time}.csv" />
<target name="all">
<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}">
<!-- 声明要运行的脚本路径和文件名 ".\"标识当前路径 "*.jmx"执行全部jmeter脚本-->
<testplans dir="D:\jmeter3.3\newTest" includes="jichuziliao.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/xinjian.xsl">
<param name="dateReport" expression="${report.datestamp}"/>
<param name="titleReport" expression="${report.title}:${report.datestamp}"/>
</xslt>
<!-- 因为上面生成报告的时候,不会将相关的图片也一起拷贝至目标目录,所以,需要手动拷贝 -->
<copy todir="${jmeter.result.html.dir}">
<fileset dir="${jmeter.home}/extras">
<include name="collapse.png" />
<include name="expand.png" />
</fileset>
</copy>
</target>
</project>