JUnit报告显示空值

时间:2013-02-07 14:43:54

标签: ant junit

我正在使用JUnitReport和Ant来生成我的测试用例报告。 构建文件成功运行,但显示空值。就像在样式表中一样,我看到框架输出

  • 测试0
  • 失败0
  • 成功率NaN
  • 时间0.00

这是我的build.xml文件

<project name="JunitTest" default="test" basedir="."> 
<property name="testdir" location="./bin" /> 
<property name="srcdir" location="." /> 
<property name="full-compile" value="true" /> 
<property name="test.reports" value="./reports" />

<path id="classpath.base"/>
<path id="classpath.test">

<path id="JUnit 4.libraryclasspath">
      <pathelement location="./lib/junit-4.1.jar"/>
      <pathelement location=".lib/hamcrest-core-1.3.jar"/>
</path>

<pathelement location="${testdir}" />
<pathelement location="${srcdir}" />

<path refid="classpath.base" />

</path> 

<target name="clean" >
    <echo> CLEAN </echo>
    <delete verbose="${full-compile}"> 
        <fileset dir="${testdir}" includes="**/*.class" />
    </delete> 
</target>

<target name="compile" depends="clean">
    <echo> COMPILING </echo>
    <javac srcdir="${srcdir}" destdir="${testdir}" verbose="${full-compile}" >
        <classpath refid="classpath.test"/>
        <classpath refid="JUnit 4.libraryclasspath" />
    </javac>
</target>

<target name="test" depends="compile" >

    <junit printsummary="true" showoutput="true">
        <classpath refid="classpath.test" />
        <classpath refid="JUnit 4.libraryclasspath" />
        <formatter type="plain"  />
        <formatter type="plain"  />

        <test name="com.megacorp.projx.JUnit.AllTests" />
    </junit>

    <junitreport todir="${test.reports}" >
        <fileset dir="${test.reports}">
            <include name="TEST-*.xml" />
        </fileset>
        <report todir="${test.reports}"  format="frames" />
    </junitreport>
    <record name="${test.reports}/test-output.txt" action="start"/>
</target>

1 个答案:

答案 0 :(得分:1)

请在test

中设置todir属性
<test name="com.megacorp.projx.JUnit.AllTests"  todir="${test.reports}" />

如果您刚刚学习junit ant任务,请检查batchtest任务。它可以根据过滤器进行拾取测试。

相关问题