当前位置: 首页 > 知识库问答 >
问题:

运行ant时未发现ant-jmeter-1.1.1.jar错误

呼延原
2023-03-14

我已经有一个名为ant-jmeter-1.1.1的文件,位于路径 C:\apache-jmeter-2.13\apache-jmeter-2.13\extras

但是,当我从同一根目录运行ant命令时,出现了一个错误:

BUILD 失败的
C:\apache-jmeter-2.13\apache-jmeter-2.13\extras\build.xml:87: 参考 C:\apache-jmeter-2.13\apache-jmeter-2.13\extras\ant-jmeter-1.1.1.jar未找到。

build.xml代码:

<?xml version="1.0"?>
 <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
  limitations under the License.
-->
<project name="ant-jmeter" default="all">
<description>

    Sample build file for use with ant-jmeter.jar
    See http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php

To run a test and create the output report:
    ant -Dtest=script

To run a test only:
    ant -Dtest=script run

To run report on existing test output
    ant -Dtest=script report

The "script" parameter is the name of the script without the .jmx suffix.

Additional options:
    -Dshow-data=y - include response data in Failure Details
    -Dtestpath=xyz - path to test file(s) (default user.dir).
                     N.B. Ant interprets relative paths against the build file
    -Djmeter.home=.. - path to JMeter home directory (defaults to parent of this build file)
    -Dreport.title="My Report" - title for html report (default is 'Load Test Results')

    Deprecated:
    -Dformat=2.0 - use version 2.0 JTL files rather than 2.1

</description>

<property name="testpath" value="${user.dir}"/>
<property name="jmeter.home" value="${basedir}/.."/>
<property name="report.title" value="Load Test Results"/>

<!-- Name of test (without .jmx) -->
<property name="test" value="Test"/>

<!-- Should report include response data for failures? -->
<property name="show-data" value="n"/>

<property name="format" value="2.1"/>

<condition property="style_version" value="">
    <equals arg1="${format}" arg2="2.0"/>
</condition>

<condition property="style_version" value="_21">
    <equals arg1="${format}" arg2="2.1"/>
</condition>

<condition property="funcMode">
    <equals arg1="${show-data}" arg2="y"/>
</condition>

<condition property="funcMode" value="false">
  <not>
    <equals arg1="${show-data}" arg2="y"/>
  </not>
</condition>

<!-- Allow jar to be picked up locally -->
<path id="jmeter.classpath">
    <fileset dir="${basedir}">
      <include name="ant-jmeter*.jar"/>
    </fileset>
</path>

<taskdef
    name="jmeter"
    classpathref="C:\apache-jmeter-2.13\apache-jmeter-2.13\extras\ant-jmeter-1.1.1.jar"
    classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>

<target name="all" depends="run,report"/>

<target name="run">
    <echo>funcMode = ${funcMode}</echo>
    <delete file="${testpath}/${test}.html"/>
    <jmeter
        jmeterhome="${jmeter.home}"
        testplan ="C:\apache-jmeter-2.13\apache-jmeter-2.13\extras\SP-TRY.jmx"
        resultlog="C:\apache-jmeter-2.13\apache-jmeter-2.13\extras\SP-TRY.jtl">
    <!--
        <jvmarg value="-Xincgc"/>
        <jvmarg value="-Xmx128m"/>
        <jvmarg value="-Dproperty=value"/>
        <jmeterarg value="-qextra.properties"/>
    -->
        <!-- Force suitable defaults -->
        <property name="jmeter.save.saveservice.output_format" value="xml"/>
        <property name="jmeter.save.saveservice.assertion_results" value="all"/>
        <property name="jmeter.save.saveservice.bytes" value="true"/>
        <property name="file_format.testlog" value="${format}"/>
        <property name="jmeter.save.saveservice.response_data.on_error" value="${funcMode}"/>
    </jmeter>
</target>

<property name="lib.dir" value="${jmeter.home}/lib"/>

<!-- Use xalan copy from JMeter lib directory to ensure consistent processing with Java 1.4+ -->
<path id="xslt.classpath">
    <fileset dir="${lib.dir}" includes="xalan*.jar"/>
    <fileset dir="${lib.dir}" includes="serializer*.jar"/>
</path>

<target name="report" depends="xslt-report,copy-images">
    <echo>Report generated at ${report.datestamp}</echo>
</target>

<target name="xslt-report" depends="_message_xalan">
    <tstamp><format property="report.datestamp" pattern="yyyy/MM/dd HH:mm"/></tstamp>
    <xslt
        classpathref="xslt.classpath"
        force="true"
        in="C:\apache-jmeter-2.13\apache-jmeter-2.13\extras\SP-TRY.jtl"
        out="C:\apache-jmeter-2.13\apache-jmeter-2.13\extras\SP-TRY.html"
        style="${basedir}/jmeter-results-detail-report${style_version}.xsl">
        <param name="showData" expression="${show-data}"/>
        <param name="titleReport" expression="${report.title}"/>
        <param name="dateReport" expression="${report.datestamp}"/>
    </xslt>
</target>

<!-- Copy report images if needed -->
<target name="copy-images" depends="verify-images" unless="samepath">
    <copy file="${basedir}/expand.png" tofile="${testpath}/expand.png"/>
    <copy file="${basedir}/collapse.png" tofile="${testpath}/collapse.png"/>
</target>

<target name="verify-images">
    <condition property="samepath">
            <equals arg1="${testpath}" arg2="${basedir}" />
    </condition>
</target>

<!-- Check that the xalan libraries are present -->
<condition property="xalan.present">
      <and>
          <!-- No need to check all jars; just check a few -->
        <available classpathref="xslt.classpath" classname="org.apache.xalan.processor.TransformerFactoryImpl"/>
        <available classpathref="xslt.classpath" classname="org.apache.xml.serializer.ExtendedContentHandler"/>
      </and>
</condition>

<target name="_message_xalan" unless="xalan.present">
      <echo>Cannot find all xalan and/or serialiser jars</echo>
    <echo>The XSLT formatting may not work correctly.</echo>
    <echo>Check you have xalan and serializer jars in ${lib.dir}</echo>
</target>
</project>

我错过了什么?

共有1个答案

弘承业
2023-03-14

jar 文件应放在ANT_HOME/lib 文件夹下。不在JMETER_HOME下。

如果您正在尝试使用Ant进行JMeter测试,我建议您检查这一点。http://www . testautomationguru . com/jmeter-continuous-performance-testing-part 1/

 类似资料:
  • 我在努力理解这个问题,但无法解决。这是我的问题。 我有、

  • 我想通过html显示Jmeter结果。html仪表板信息不够丰富,所以我想使用ant解决方案。 < li >我按预期安装了ant < li >我将testplan.jmx复制到C:\ Jmeter _ 4.0 \ Apache-Jmeter-4.0 \ extras < li >我将testplan.jmx更改为Test.jtl < li >我进入了cmd CD C:\ Jmeter _ 4.0

  • 很长一段时间以来,我一直面临一个问题。我想用完整的Jmeter报告创建html。唯一的解决方案是使用蚂蚁,根据一些站点运行jmeter。 我安装了ant 导航到C:\Jmeter_4.0\apache-Jmeter-4.0\extras并复制所有文件(使用ctrl A)(ctrl C) 导航到C:\ant\ant\bin并粘贴所有文件(Ctrl-v) 创建一个新的文本文件并将其命名为Test。文本

  • 我正在使用ant 1.9.0来运行我的Java项目,我有一个bat文件,它有命令ant clean compile run。clean and compile是正常的,但是对于目标运行,我得到了以下错误 我正在附加build.xml请让我知道我的build.xml中的问题 以下是错误:

  • 可以从jar文件中运行ant脚本吗? 目前,我有一个build.xml,它调用一些java代码,这些代码在一个jar文件中。然后它做一些进一步的蚂蚁处理。 当我从Eclipse导出jar文件时,我可以选择添加构建。xml文件到jar,所以我想知道我是否可以直接从jar运行ant脚本,这样我只需要给人们jar文件,而不是ant脚本。

  • 问题内容: 这是我到目前为止的内容: 但是我猜这个错误: 我尝试使用以下方法指定项目: 但是没有运气。 指定的ant文件是正确的,因为它可以从命令行正常运行。 更新 经过更多搜索后,我到达了这里:http : //onjava.com/pub/a/onjava/2002/07/24/antauto.html?page=1 这是一个很棒的教程。 这是我在下面的答案中看到代码之前得到的代码: 但是由于