Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output failed test details to stdout using maven surefire

Tags:

When I run my build using maven 2

mvn clean install 

my tests are run by surefire plug-in. In case test failed I get the following output:

Results :  Failed tests:    test1(com.my.MyClassTest)  Tests run: 3, Failures: 1, Errors: 0, Skipped: 0  [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] There are test failures.  Please refer to /home/user/myproject/mymodule/target/surefire-reports for the individual test results. 

To get the details about the problem I have to go and check surefire reports folder. Doing this every time my tests fail becomes annoying. Is there any way I can get those details (assert message + exception + stack trace) right here on the stdout ?

like image 939
pavel_kazlou Avatar asked Nov 18 '11 09:11

pavel_kazlou


People also ask

How to rerun failed test cases in maven?

During development, you may re-run failing tests because they are flaky. To use this feature through Maven surefire, set the rerunFailingTestsCount property to be a value larger than 0. Tests will be run until they pass or the number of reruns has been exhausted.

What is argLine in surefire?

Since the Version 2.17 using an alternate syntax for argLine , @{... } allows late replacement of properties when the plugin is executed, so properties that have been modified by other plugins will be picked up correctly.

How do I disable surefire report in Maven?

1 Answer. Show activity on this post. https://maven.apache.org/surefire/maven-surefire-report-plugin/report-mojo.html#skipSurefireReport. this code will skip the surefire tests.


1 Answers

I find there's way too much output produced on stdout to be useful. Try leaving the HTML report open in your browser. After running your tests just refresh the page. Have a look at target/surefire-reports/index.html.

To output test results to stdout rather than a file use the following command:

mvn test -Dsurefire.useFile=false 

Or to configure in your pom.xml add the following to your plugins section.

<plugin>   <artifactId>maven-surefire-plugin</artifactId>   <version>2.10</version>   <configuration>     <useFile>false</useFile>   </configuration> </plugin> 
like image 104
orien Avatar answered Nov 05 '22 06:11

orien