Maven,显示当前正在运行的单元测试 [英] Maven, displaying unit test currently running

查看:127
本文介绍了Maven,显示当前正在运行的单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司最近改用了Maven,过渡非常顺利,但是有一个让我感到烦恼的事情. 因此,在更早的Maven时代,您可以看到正在运行当前类的测试(例如,如果您在一个类中有40个单元测试,而第二个测试失败,您将看到它). 现在,它看起来是这样的:它显示测试过的类的名称,仅此而已.您必须等到类中的所有测试都完成才能真正看到结果(可以停止测试,它会显示进度到停止点,但是在实际停止测试之前您什么也看不到).在某些集成测试中,这确实很烦人和耗时.

My company has recently switched to maven, and the transition was very smooth, but there is one this that annoys me. So earlier, in pre-maven era you could see which test is current class is being run (f.e if you had 40 unit tests in a class, and 2nd test failed you would see it). Now it looks this way: it displays the name of tested class and thats it. You have to wait till all the tests are done in the class to actually see the results (you can stop the test and it will show the progress to the point you stopped, but you don't see anything before actually stopping them). This is really annoying and time consuming in some integration tests.

如果有人知道解决方案,我将不胜感激.预先感谢.

If anyone knows a solution for this I'd be grateful. Thanks in advance.

推荐答案

您可以配置一个侦听器,该侦听器将在控制台上打印当前运行的测试.请参阅 junit maven-surefire-plugin的Using custom listeners and reporters部分.文档 testng maven-surefire-plugin文档

You can configure a listener that will print the currently run test on the console. See the sections Using custom listeners and reporters of the junit maven-surefire-plugin documentation or the testng maven-surefire-plugin documentation

  <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>

这篇关于Maven,显示当前正在运行的单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆