构建失败,通过 ANT 执行 junit 测试用例时未生成报告



我正在尝试使用ant来运行junit测试并生成报告。它给出错误"BUILD FAILED",并且没有生成报告。junit报表文件夹为空。我做错了什么?

这是我的build.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
          Any modifications will be overwritten.
          To include a user specific buildfile here, simply create one in the same
          directory with the processing instruction <?eclipse.ant.import?>
          as the first entry and export the buildfile again. --><project basedir="." default="build" name="SeleniumProject">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../../eclipse-jee-indigo-SR2-win32-x86_64/eclipse"/>
<property name="junit.output.dir" value="junit"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.7"/>
<property name="source" value="1.7"/>
<path id="JUnit 4.libraryclasspath">
    <pathelement location="${ECLIPSE_HOME}/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar"/>
    <pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
</path>
<path id="SeleniumProject.classpath">
    <pathelement location="bin"/>
    <path refid="JUnit 4.libraryclasspath"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/selenium-java-2.41.0.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/selenium-java-2.41.0-srcs.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/selenium-server-standalone-2.41.0.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/apache-mime4j-0.6.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/bsh-1.3.0.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/cglib-nodep-2.1_3.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-codec-1.8.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-collections-3.2.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-exec-1.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-io-2.2.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-jxpath-1.3.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-lang3-3.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-logging-1.1.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/cssparser-0.9.11.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/guava-15.0.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/hamcrest-core-1.3.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/hamcrest-library-1.3.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/htmlunit-2.13.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/htmlunit-core-js-2.13.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/httpclient-4.3.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/httpcore-4.3.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/httpmime-4.3.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/ini4j-0.5.2.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/jcommander-1.29.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/jetty-websocket-8.1.8.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/jna-3.4.0.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/jna-platform-3.4.0.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/json-20080701.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/junit-dep-4.11.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/nekohtml-1.9.19.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/netty-3.5.7.Final.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/operadriver-1.5.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/phantomjsdriver-1.1.0.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/protobuf-java-2.4.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/sac-1.3.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/serializer-2.7.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/testng-6.8.5.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/xalan-2.7.1.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/xercesImpl-2.10.0.jar"/>
    <pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/xml-apis-1.4.01.jar"/>
</path>
<target name="init">
    <mkdir dir="bin"/>
    <copy includeemptydirs="false" todir="bin">
        <fileset dir="src">
            <exclude name="**/*.launch"/>
            <exclude name="**/*.java"/>
        </fileset>
    </copy>
</target>
<target name="clean">
    <delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
    <echo message="${ant.project.name}: ${ant.file}"/>
    <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
        <src path="src"/>
        <classpath refid="SeleniumProject.classpath"/>
    </javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
    <copy todir="${ant.library.dir}">
        <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
    </copy>
    <unzip dest="${ant.library.dir}">
        <patternset includes="jdtCompilerAdapter.jar"/>
        <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
    </unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
    <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
    <antcall target="build"/>
</target>
<target name="absolutexpath (1)">
    <mkdir dir="${junit.output.dir}"/>
    <junit fork="yes" printsummary="withOutAndErr">
        <formatter type="xml"/>
        <test name="absolutexpath" todir="${junit.output.dir}"/>
        <classpath refid="SeleniumProject.classpath"/>
    </junit>
</target>
<target name="dropdown">
    <java classname="DropDown" failonerror="true" fork="yes">
        <classpath refid="SeleniumProject.classpath"/>
    </java>
</target>
<target name="relativexpath (1)">
    <mkdir dir="${junit.output.dir}"/>
    <junit fork="yes" printsummary="withOutAndErr">
        <formatter type="xml"/>
        <test name="relativexpath" todir="${junit.output.dir}"/>
        <classpath refid="SeleniumProject.classpath"/>
    </junit>
</target>
<target name="verifytextbycss">
    <mkdir dir="${junit.output.dir}"/>
    <junit fork="yes" printsummary="withOutAndErr">
        <formatter type="xml"/>
        <test name="Verifytextbycss" todir="${junit.output.dir}"/>
        <classpath refid="SeleniumProject.classpath"/>
    </junit>
</target>
<target name="Verifytextbyid (1)">
    <mkdir dir="${junit.output.dir}"/>
    <junit fork="yes" printsummary="withOutAndErr">
        <formatter type="xml"/>
        <test name="Verifytextbyid" todir="${junit.output.dir}"/>
        <classpath refid="SeleniumProject.classpath"/>
    </junit>
</target>
<target name="verifytitle (1)">
    <mkdir dir="${junit.output.dir}"/>
    <junit fork="yes" printsummary="withOutAndErr">
        <formatter type="xml"/>
        <test name="verifytitle" todir="${junit.output.dir}"/>
        <classpath refid="SeleniumProject.classpath"/>
    </junit>
</target>
<target name="junitreport">
    <junitreport todir="${junit.output.dir}">
        <fileset dir="${junit.output.dir}">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="${junit.output.dir}"/>
    </junitreport>
</target>

这是控制台的输出:

Buildfile: C:UsersRoshanworkspaceSeleniumProjectbuild.xml
build-subprojects:
init:
build-project:
 [echo] SeleniumProject: C:UsersRoshanworkspaceSeleniumProjectbuild.xml
[javac] C:UsersRoshanworkspaceSeleniumProjectbuild.xml:78: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
build:
junitreport:
[junitreport] Processing C:UsersRoshanworkspaceSeleniumProjectjunitTESTS-TestSuites.xml to C:Windowsnull231041511
[junitreport] Loading stylesheet jar:file:/C:/apache-ant-1.9.4-bin/apache-ant-1.9.4/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] Failed to process C:UsersRoshanworkspaceSeleniumProjectjunitTESTS-TestSuites.xml
BUILD FAILED
C:UsersRoshanworkspaceSeleniumProjectbuild.xml:143: Errors while applying transformations: java.io.FileNotFoundException: C:Windowsnull231041511 (Access is denied)
Total time: 942 milliseconds

Junit测试在absoluteexpath和relativexpath目标中运行。我在"dependents"属性中看不到这两个。您的输出意味着它们也没有运行。

此外,你会得到这样的信息:

C: \Windows\null231041511(访问被拒绝)

你能指向一个像c:\temp这样有读写权限的目录吗?

相关内容

  • 没有找到相关文章

最新更新