jmeter+ant运行报错:
BUILD FAILED
/Users/chenjiawei/Downloads/apache-ant-1.10.6/report/concise/build.xml:19: The following error occurred while executing this line:
/Users/chenjiawei/Downloads/apache-ant-1.10.6/report/concise/build.xml:23: taskdef class org.programmerplanet.ant.taskdefs.jmeter.JMeterTask cannot be found
using the classloader AntClassLoader[]
报错截图:
网上说把jmeter/extras目录下的ant-jmeter-1.1.1.jar复制到ant/lib目录下就行了,可是我试了还是不行,报同样的错,求各位大神支招
我的build.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant-jmeter-test" default="run" basedir=".">
<tstamp>
<format property="time" pattern="yyyyMMddhhmm" />
</tstamp>
<!-- 需要改成自己本地的 Jmeter 目录-->
<property name="jmeter.home" value="/Users/chenjiawei/Downloads/apache-jmeter-5.1.2.1/extras" />
<!-- jmeter生成jtl格式的结果报告的路径-->
<property name="jmeter.result.jtl.dir" value="/Users/chenjiawei/Downloads/apache-ant-1.10.6/resultLog/jtl" />
<!-- jmeter生成html格式的结果报告的路径-->
<property name="jmeter.result.html.dir" value="/Users/chenjiawei/Downloads/apache-ant-1.10.6/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="run">
<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="/Users/chenjiawei/Downloads/apache-jmeter-5.1.2.1/test" includes="baidu.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/jmeter-results-detail-report_21.xsl" >
<param name="dateReport" expression="${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>
换个包试试
将jmeter/extras文件夹下的ant-jmeter-1.1.3.jar文件拷贝到ant/lib路径下
你是指重新换个jmeter的包然后把下边的ant-jmeter-1.1.1.jar复制过去嘛
@回忆式~过去: 嗯 试下其他jar包
@ycyzharry: 换了好几个jar包都不行,还提示的是taskdef class org.programmerplanet.ant.taskdefs.jmeter.JMeterTask cannot be found
using the classloader AntClassLoader[]
对了,补充一下,我用的mac机子
自己的环境有问题,发现自己同一个ant安装到了两个地方,变量配置的A地方,build配置的B地方
请问这个问题,如何处理呢
@•两个兵•: 删除不用的ant包,重新配置好环境,保证变量和build配置的路径一致正确