Maven, don't swallow the stacktraces from failing JUnit tests!


If you've got a test like this:

@Test
public void canSayFoo() throws Exception {
  // some code that throws an exception
}

then mvn will just print the exception on one line, stating the line in the unit tests and not the line where the error originated. I find it strange that this has become the default behaviour of the sure fire plugin. Fortunately, you can get the stack traces back by passing this parameter:

-DtrimStackTrace=false

or configuring the surefire plugin in your pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
        <trimStackTrace>false</trimStackTrace>
    </configuration>
</plugin>

Licensed under CC BY Creative Commons License ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@emacs.ch ~ 🐦 @torsteinkrause