我的公司最近转向了maven,过渡非常顺利,但有一个令我烦恼。 所以早些时候,在pre-maven时代你可以看到哪个测试是当前正在运行的类(如果你在一个类中有40个单元测试,第二个测试失败你会看到它)。 现在它看起来像这样:它显示测试类的名称,就是这样。你必须等到在课堂上完成所有测试才能真正看到结果(你可以停止测试,它会显示你停止的点的进度,但是在实际停止之前你没有看到任何东西)。在某些集成测试中,这非常烦人且耗时。
如果有人知道解决方案,我将不胜感激。提前谢谢。
答案 0 :(得分:5)
您可以配置一个侦听器,该侦听器将在控制台上打印当前运行的测试。请参阅junit maven-surefire-plugin documentation或testng maven-surefire-plugin documentation
的Using custom listeners and reporters
部分
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<properties>
<property>
<name>listener</name>
<value>com.mycompany.MyResultListener,com.mycompany.MyResultListener2</value>
</property>
</properties>
</configuration>
</plugin>
答案 1 :(得分:1)
如果您使用JUnit,则could use a @Rule
for this。
如果您只想在Maven运行测试时应用它,请使用System属性来禁用输出。