我正在使用Junit 4.4和Ant 1.7.如果测试用例失败并出现错误(例如,因为某个方法引发了意外异常),我不会获得有关错误的详细信息.
我的build.xml看起来像这样:
<target name="test" depends="compile">
<junit printsummary="withOutAndErr" filtertrace="no" fork="yes" haltonfailure="yes" showoutput="yes">
<classpath refid="project.run.path"/>
<test name="a.b.c.test.TestThingee1"/>
<test name="a.b.c.test.NoSuchTest"/>
</junit>
</target>
Run Code Online (Sandbox Code Playgroud)
当我运行"ant test"时,它说(例如)2次测试运行,0次失败,1次错误.它没有说"没有NoSuchTest这样的测试",即使这是完全合理的,并且让我弄清楚错误的原因.
谢谢!
-担
use*_*762 32
弄清楚了 :)
我需要在junit块中添加一个"formatter".
<formatter type="plain" usefile="false" />
Run Code Online (Sandbox Code Playgroud)
什么是PITA.
-担
如果您要进行大量测试,则可能需要考虑两项更改:
使用junitreport任务很容易:
<target name="test">
<mkdir dir="target/test-results"/>
<junit fork="true" forkmode="perBatch" haltonfailure="false"
printsummary="true" dir="target" failureproperty="test.failed">
<classpath>
<path refid="class.path"/>
<pathelement location="target/classes"/>
<pathelement location="target/test-classes"/>
</classpath>
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest todir="target/test-results">
<fileset dir="target/test-classes" includes="**/*Test.class"/>
</batchtest>
</junit>
<mkdir dir="target/test-report"/>
<junitreport todir="target/test-report">
<fileset dir="target/test-results">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="target/test-report"/>
</junitreport>
<fail if="test.failed"/>
</target>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10032 次 |
| 最近记录: |