Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven not showing which tests failed in command prompt

When I run a mvn test from the command prompt it doesn't show which tests failed at the end of the build. Shouldn't the tests that failed be listed under Tests in error?? I'm using windows xp :( and I've tried in the command prompt and console2.

Results :

Tests in error:

Tests run: 402, Failures: 0, Errors: 1, Skipped: 2

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.

Please refer to C:\code\btlims\java\chippingmanager\chipping-manager-client\target\surefire-reports for the individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 minutes 27 seconds
[INFO] Finished at: Tue Mar 29 09:19:58 CDT 2011
[INFO] Final Memory: 24M/43M
[INFO] ------------------------------------------------------------------------
like image 858
Scott Avatar asked Mar 29 '11 14:03

Scott


People also ask

Why your JUnit 4 tests are not running under Maven?

Until JUnit 4, Maven will only run the test classes which are marked as public. We should note, though, that this won't be an issue with JUnit 5+. However, the actual test methods should always be marked as public. Here, we can notice that the test method is marked as private.

Why tests are skipped Maven surefire plugin?

When the Surefire plugin reaches the test goal, it will skip the unit tests if the maven. test. skip properties is set to true . Another way to configure Maven to skip unit tests is to add this configuration to your project's pom.

Which command of Maven is used to run all unit tests?

We can run our unit tests with Maven by using the command: mvn clean test. When we run this command at command prompt, we should see that the Maven Surefire Plugin runs our unit tests.


1 Answers

I have encountered this issue using Maven 3.0.3 and version 2.8 of the maven-surefire-plugin. In the surefire plugin section of your pom.xml, ensure that the printSummary option is set to true.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <printSummary>true</printSummary>
            </configuration>
        </plugin>

Once this option is set, you should see the full list of test results (including failures) in your command-line output. According to the Surefire documentation, tests cases that fail should still be listed when this option is set to false but that does not appear to be the case on my setup.

like image 66
DrewCo Avatar answered Sep 30 '22 11:09

DrewCo