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 开发者_StackOverflow:( 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] ------------------------------------------------------------------------
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.
Test errors are test which are exited because of an exception.
Test failures are tests where an assertion did not match/pass.
You are right - both events should be reported at the end.
I tried it this way
import static org.junit.Assert.fail;
import org.junit.Test;
public class FooBarTest {
@Test
public void testError() {
throw new RuntimeException();
}
@Test
public void testFailure() {
fail();
}
}
This causes the following output
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running FooBarTest
Tests run: 2, Failures: 1, Errors: 1, Skipped: 0, Time elapsed: 0.09 sec <<< FAILURE!
Results :
Failed tests:
testFailure(FooBarTest)
Tests in error:
testError(FooBarTest)
Tests run: 2, Failures: 1, Errors: 1, Skipped: 0
You should follow the advice and take a look at the target\surefire-reports
. Maybe post the affected report to give us more information.
If possible maybe update your maven version.
精彩评论