想达到 ant 执行 jmeter 并生成报表
执行命名:ant all
ant test 能够成功
ant report 内容时报错:
rg.xml.sax.SAXParseException; systemId: file:/E:/apps/jmeter/resultLog/jtl/Tes
eport201506030623.jtl; lineNumber: 1; columnNumber: 1; 前言中不允许有内容。
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant-jmeter-test" default="all" basedir=".">
<tstamp>
<format property="time" pattern="yyyyMMddhhmm" />
</tstamp>
<property name="jmeter.home" value="D:\app\apache-jmeter-2.13" />
<property name="jmeter.result.jtl.dir" value="E:\apps\jmeter\resultLog\jtl" />
<property name="jmeter.result.html.dir" value="E:\apps\jmeter\resultLog\html" />
<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" />
<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}">
<testplans dir="E:\apps\jmeter\testCase" includes="*.jmx" />
</jmeter>
</target>
<target name="report">
<xslt in="${jmeter.result.jtlName}"
out="${jmeter.result.htmlName}"
style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl" />
<copy todir="${jmeter.result.html.dir}">
<fileset dir="${jmeter.home}/extras">
<include name="collapse.png" />
<include name="expand.png" />
</fileset>
</copy>
</target>
</project>
jtl 文件格式如下:
1433328700047,1079,HTTP Request,200,OK,Thread Group 1-1,text,true,94015,10,10,964
1.bulid.xml 是 utf-8 格式文件
2.jmeter.properties 文件设置 sampleresult.default.encoding=utf-8
还是不行,在生成报表依然报 前言中不允许有内容
3.是我粗心在修改 jmeter.save.saveservice.output_format=XML
应该改成 jmeter.save.saveservice.output_format=xml
所以提醒下大家在设置 jmeter 的属性时,要区分大小写