如何在不将测试结果打印到命令行的情况下运行Maven surefire? [英] How to run Maven surefire without printing out test results to the command line?

查看:110
本文介绍了如何在不将测试结果打印到命令行的情况下运行Maven surefire?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Maven 3.1.0 Surefire插件 使用--quiet选项已经,但是它仍然将单元测试的结果打印出到命令行,即使它们都通过了也是如此. 有没有办法让它仅打印失败?

I am running the Maven 3.1.0 Surefire plugin already with the --quiet option, however it still prints out the results of unit tests out to the command line, even if they all pass. Is there a way to only get it to print failures?

如果一切都很好,我想抑制的输出如下:

The output I'd like to suppress if everything is fine looks like:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running net.initech.project.dawgs.actionfactory.InterfaceActionFactoryTest
Tests run: 14, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.425 sec
Running net.initech.project.dawgs.actionfactory.ValueScopeTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Running net.initech.project.dawgs.assertion.AssertContainsTest
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 sec
Running net.initech.project.assertion.AssertEndsWithTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 sec
Running net.initech.project.assertion.AssertIsEqualTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
Running net.initech.project.assertion.AssertIsLikeTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 sec
Running net.initech.project.assertion.AssertStartsWithTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec

Results :

Tests run: 52, Failures: 0, Errors: 0, Skipped: 0

否,我不想将输出通过管道传输到/dev/null

No, I do not want to pipe the output to /dev/null

推荐答案

尝试将surefire.printSummary属性设置为false:

Try setting the surefire.printSummary property to false: this should only print the test cases that have errors. So try running it as mvn -q -Dsurefire.printSummary=false.

或者,您可以将其放入pom.xml中.

Alternatively, you can put it in your pom.xml:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>            
      <printSummary>false</printSummary> 
    </configuration>
  </plugin>

这篇关于如何在不将测试结果打印到命令行的情况下运行Maven surefire?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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