1

当我试图在没有junitreport正常工作的情况下进行构建时。但是,我最终需要 html 格式的 junit 报告以及所有成功或失败的脚本。请建议我哪里出错了。任何帮助,将不胜感激。

<?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="JavaP">
    <property environment="env"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.6"/>
    <property name="source" value="1.6"/>
    <path id="JavaP.classpath">
        <pathelement location="bin"/>
        <pathelement location="../../Sel JAR/junit-4.8.1.jar"/>
        <pathelement location="../../Sel JAR/jxl.jar"/>
        <pathelement location="../../Sel JAR/poi-3.7.jar"/>
        <pathelement location="../../Sel JAR/reportng-1.1.3.jar"/>
        <pathelement location="../../Sel JAR/selenium-java-2.29.0.jar"/>
        <pathelement location="../../Sel JAR/selenium-server-2.29.0.jar"/>
        <pathelement location="../../Sel JAR/selenium-server-standalone-2.29.0.jar"/>
        <pathelement location="../../Sel JAR/testng-6.5.2.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}" includeantruntime="false">
            <src path="src"/>
            <classpath refid="JavaP.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="JavaP">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="seleniumtest.Helloworld" todir="${junit.output.dir}"/>
            <test name="seleniumtest.Testclass" todir="${junit.output.dir}"/>
            <classpath refid="JavaP.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>
</project>

错误详情

Buildfile: D:\Seljava\JavaP\build.xml
build-subprojects:
init:
build-project:
     [echo] JavaP: D:\Seljava\JavaP\build.xml
build:
junitreport:
[junitreport] Processing D:\Seljava\JavaP\junit\TESTS-TestSuites.xml to C:\Users\nitinl\AppData\Local\Temp\null1642041795
[junitreport] Loading stylesheet jar:file:/D:/Eclipse-Workspace/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
[junitreport] : Error! Could not compile stylesheet
[junitreport] : Fatal Error! Could not compile stylesheet Cause: Cannot convert data-type 'void' to 'reference'.
[junitreport] Failed to process D:\Seljava\JavaP\junit\TESTS-TestSuites.xml

BUILD FAILED
D:\Seljava\JavaP\build.xml:70: Errors while applying transformations: Fatal error during transformation

Total time: 450 milliseconds
4

3 回答 3

2

从 Java 6 升级到 Java 7 后,我遇到了同样的问题。我可以通过使用 Ant 1.9.0 在命令行上运行 ant 来解决这个问题。

不幸的是,在 Eclipse 中切换到 Ant 1.9.0(根据这些说明:How to upgrade the ant built into eclipse?)在 Eclipse 中运行 Ant 时并没有解决问题,但是在命令行上运行是有效的,所以这就是我在用着。

于 2013-09-10T20:54:14.617 回答
0

这是蚂蚁内部的问题...

您可以通过从 ant 主页下载两个 jar 来解决此问题:org.apache.xalan org.apache.xml.serializer

将这些文件放在 C:\Windows\Sun\Java\lib\ext 下面,在我的情况下,lib 和 ext 文件夹不存在,如果是这种情况,只需创建它们。重新启动eclipse,一切都会正常工作。(它在两台电脑上对我有用,而且我主题的很多伙伴也有同样的问题,这个解决方案对所有人都有效)

问候

于 2014-01-21T13:58:51.643 回答
0

我在使用 ant 1.8.4 和 java 5 或 6 从 eclipse kepler 运行时遇到了同样的问题。
它在命令行 ant 1.7.0 和 java 5 或 6 中运行。

于 2013-12-17T20:00:13.333 回答