我有一个单元测试,它包含6个测试用例(@Test
-annotated方法),当我将Java文件作为JUnit测试运行时(从Eclipse工作台内部运行) 。但是,当我去从buildscript运行run-tests
Ant目标,他们失败,出现以下控制台输出:JUnit测试在Eclipse工作台中传递,但在Ant中失败
[junit] Running com.me.myproject.WidgetTest
[junit] Tests run: 6, Failures: 6, Errors: 0, Time elapsed: 1.737 sec
[junit] Test com.me.myproject.WidgetTest FAILED
这里是run-tests
目标的JUnit的部分:
<junit fork="yes" forkmode="once" dir="${basedir}" printsummary="yes" haltonerror="no" haltonfailure="no">
<classpath>
<path refid="test.class.path"/>
<pathelement location="${mainBuildDir}"/>
<pathelement location="${testBuildDir}"/>
</classpath>
<formatter type="xml"/>
<batchtest todir="${genUnitTestReportsDir}">
<fileset dir="${testJavaSrcDir}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
有人曾经听到这种情况?有没有办法从JUnit的ant任务中获得更多(详细)输出?有什么好的方法来调试这里发生的事情?提前致谢!
最简单的调试方法是在测试中添加一堆System.out.println语句,以查看发生了什么。 – yatskevich 2012-01-17 12:43:18
顺便说一句,看看junit Ant任务的'showoutput'参数。 http://ant.apache.org/manual/Tasks/junit.html – yatskevich 2012-01-17 12:46:29
你有失败测试的输出吗? – helios 2012-01-17 14:10:38