7

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

如果一切正常,我想抑制的输出如下所示:

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

4

1 回答 1

7

尝试将surefire.printSummary属性设置为false:这应该只打印有错误的测试用例。所以尝试将其运行为mvn -q -Dsurefire.printSummary=false.

或者,你可以把它放在你的 pom.xml 中:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>            
      <printSummary>false</printSummary> 
    </configuration>
  </plugin>
于 2013-08-28T13:33:19.530 回答