Update: I’ve modified the post to reflect more accurately where the Surefire plugin keeps its details.
I thought I’d write about a common problem I have when developing under Maven2. Actually it’s too early to call it a common problem since I’ve only started about 7-10 Maven2 projects, but it’s common enough across these projects that I feel I should write about it. The problem is finding what’s wrong with a failing test in a build. By default the Surefire plugin offers no info relevant to the failing test on screen other than there was a test failure. The idea behind that is you are more than likely to use your IDE or a separate invocation of your unit test tool to get more detailed information. Also, the surefire plugin is designed to cellect test details in batch for formatting on an eventual site where project details can be broswed. One handy feature I found is a setting to get Surefire to log the details of the failed test. There is a property that can be set in either your POM or on the command line to get the details. On the command line (which is the more likely place you’ll use it) the setting is:
-Dsurefire.useFile=false. This can also be set in your POM in the configuration section for the Surefire plugin.
Running the test phase after setting that configuration will display all relevant details of test failures on the screen.