use*_*000 11 eclipse ant junit
我试图让ANT在Eclipse中创建一个JUNIT测试的HTML报告,但在我创建ANT版本后,运行它时会出现以下错误:
[junitreport] Processing C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml to C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\null785926900
[junitreport] Loading stylesheet jar:file:/C:/ANT/apache-ant-1.8.3/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! Cannot convert data-type 'void' to 'reference'.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml
我需要做些什么来解决这个问题?
以下是我正在尝试运行的Build.xml的部分:
<target name="Home">
    <mkdir dir="${junit.output.dir}"/>
    <junit fork="yes" printsummary="withOutAndErr">
        <formatter type="xml"/>
        <test name="Home" todir="${junit.output.dir}"/>
        <classpath refid="Home.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>
Kal*_*Kal 16
当我收到此错误时,我必须右键单击Eclipse中的build.xml文件,选择"Run as Ant build ..."选项(菜单中的第3个)然后单击JRE选项卡并选择"Run in the与工作区"选项相同的JRE,然后继续运行脚本.出于某种原因,这解决了这个问题.老实说,我不知道为什么.
小智 9
Eclipse Bug明确记录了Bug 384757.分析表明Oracle引入了这个bug.我需要Java版本7但JunitReport需要Java版本5和早期版本的Java版本6.显而易见的方法是在未来版本中由Oracle修复Java问题时将"bootclasspath"参数添加到Ant junitreport任务.不幸的是,Ant task junitreport不支持bootclasspath选项.这是支持Ant的人可以做的吗?
小智 1
如果您使用带有 JDK 1.7 的 Eclipse/JUnit 报告,请使用 JDK 1.6。JDK 1.7 中存在一个错误,Eclipse/JUnit 报告与您所描述的类似。这可能是类似的报告:https://netbeans.org/bugzilla/show_bug.cgi ?id=201022