Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 使用ANT创建HTML(junit样式)报表时出现的问题_File_Ant_Build_Jmeter - Fatal编程技术网

File 使用ANT创建HTML(junit样式)报表时出现的问题

File 使用ANT创建HTML(junit样式)报表时出现的问题,file,ant,build,jmeter,File,Ant,Build,Jmeter,我试图使用ANT为jMeter测试生成一个HTML/Junit样式的报告。我已经为此创建了一个构建文件,并完成了以下所有先决条件: 设置所需变量,如java home、ant home、path变量;将ant构建文件和所需的.jmx文件(用于jmeter执行)放在一个文件夹中,并调用指向同一文件夹的“ant”命令。 我尝试通过以ant和ant-Dtest=“Sample Workload Script”的形式发出命令来调用ant构建文件 我遇到的问题是,当我运行这个命令时,它会执行测试计划,然后

我试图使用ANT为jMeter测试生成一个HTML/Junit样式的报告。我已经为此创建了一个构建文件,并完成了以下所有先决条件: 设置所需变量,如java home、ant home、path变量;将ant构建文件和所需的.jmx文件(用于jmeter执行)放在一个文件夹中,并调用指向同一文件夹的“ant”命令。 我尝试通过以ant和ant-Dtest=“Sample Workload Script”的形式发出命令来调用ant构建文件

我遇到的问题是,当我运行这个命令时,它会执行测试计划,然后给出一个java平台错误(如附图所示),并停止构建。有没有什么线索可以说明是什么原因造成的

我在某处读到ANT版本可能与Java1.8不兼容。说到这里,我正在使用Ant1.9.7和Java1.8.73

我的生成文件:

<?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="testpath" value="${user.dir}"/>-->
    <property name="jmeter.home" value="C:\apache-jmeter-3.0"/>
    <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"
        classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
    <!--classpathref="jmeter.classpath"-->
    <!--classpathref="C:\apache-jmeter-3.0\extras"-->

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

    <target name="run">
        <echo>funcMode = ${funcMode}</echo>
        <delete file="${testpath}/${test}.html"/>
        <jmeter
            jmeterhome="${jmeter.home}"
            testplan ="${basedir}/${test}.jmx"          
            resultlog="${basedir}/${test}.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="${basedir}/${test}.jtl"
            out="${basedir}/${test}.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>

用于ant-jmeter.jar的样例构建文件
看见http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php
要运行测试并创建输出报告,请执行以下操作:
ant-Dtest=script
要仅运行测试,请执行以下操作:
ant-Dtest=脚本运行
对现有测试输出运行报告
ant-Dtest=脚本报告
“script”参数是不带.jmx后缀的脚本名称。
其他选择:
-Dshow data=y-在故障详细信息中包含响应数据
-Dtestpath=xyz—测试文件的路径(默认user.dir)。
注意:Ant根据构建文件解释相对路径
-Djmeter.home=…-JMeter主目录的路径(默认为此生成文件的父目录)
-Dreport.title=“我的报告”-html报告的标题(默认为“负载测试结果”)
不赞成:
-Dformat=2.0-使用2.0版JTL文件,而不是2.1版
funcMode=${funcMode}
在${Report.datestamp}生成的报表
找不到所有xalan和/或serialiser JAR
XSLT格式可能无法正常工作。
检查${lib.dir}中是否有xalan和序列化程序JAR
更新
build.xml
文件的“jmeter”部分,如下所示:

<jmeter
    jmeterhome="${jmeter.home}"
    testplan ="${basedir}/${test}.jmx"          
    resultlog="${basedir}/${test}.jtl"
    jmeterlogfile="${basedir}/jmeter.log"> <!-- add this line to enabled logging-->

重新运行测试并查看
C:\workspace\CPT
文件夹下的jmeter.log文件-它应该包含足够的疑难解答信息,以便您能够找到原因。如果您在解释日志文件时遇到问题,请将其添加到您的问题中

参考资料:


我添加了线路并运行了它。它没有在基本目录中提供任何jmeter.log文件。顺便说一句,在检查java版本时存在歧义。在执行java-version时,它显示
java版本“1.8.0_73”java(TM)SE运行时环境(build 1.8.0_73-b02)java热点(TM)64位服务器VM(build 25.73-b02,混合模式)
。当我使用javac-version时,它会显示
javac1.8.0\u60
。这能成为核心问题吗?