我们目前在构建中使用JUnit 4.4和Ant 1.7.1。我有一些测试用例被@Ignore标记。当我在Eclipse中运行它们时,JUnit测试运行器会将它们报告为已忽略。我想在Ant的XML输出中看到它们的列表(这样我就可以报告它们),但似乎没有出现在那里。是否有人成功实现了这个功能?是否有开关可以打开它们?还是需要升级?
看起来这是一个已知的Ant问题/缺陷。
这个帖子讨论了同样的问题,但它提供了一些额外的信息:当使用Maven Surefire运行测试时,您可以获取有关被忽略测试的数据,并且Hudson能够显示这些数据。
http://jenkins.361315.n4.nabble.com/Is-it-possible-to-show-Ignore-JUnit-tests-td1565288.html
刚试了Ant 1.9.0和JUnit 4.11。如果你使用<junit printsummary="on">
,你会得到如下输出:
[junit] Running com.example.IgnoredTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.01
[junit] Running com.example.PassingTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01
[junit] Running com.example.FailingTest
[junit] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.01
我认为如果我们能够使用printsummary=off
来获得这样的输出,那将是更好的选择:
[junit] Test com.example.IgnoredTest SKIPPED
[junit] Test com.example.FailingTest FAILED
但是除非我错过了某个junit任务参数的晦涩技巧,否则似乎上面更冗长的输出是我们能做到的最好的。