Make maven's surefire show stacktrace in console

MavenUnit TestingStack TraceMaven Surefire-Plugin

Maven Problem Overview


I'd like to see the stacktrace of unit tests in the console. Does surefire support this?

Maven Solutions


Solution 1 - Maven

A related problem that I found is that surefire in recent versions apparently sets trimStackTrace to true by default (rendering most stack trace in failed tests useless), which is quite inconvenient.

Setting -DtrimStackTrace=false or defining

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

solved this.

Solution 2 - Maven

You can use the following command to see the stack trace on console instead of report files in the target/surefire-reports folder:

mvn -Dsurefire.useFile=false test

Solution 3 - Maven

To extend the answer given before, you also can configure this behavior in your pom.xml:

..
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.5</version>
  <configuration>
    <useFile>false</useFile>
  </configuration>
</plugin>
..

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIAdapterView Question on Stackoverflow
Solution 1 - Mavenh7rView Answer on Stackoverflow
Solution 2 - MavenEugene KuleshovView Answer on Stackoverflow
Solution 3 - Mavenyegor256View Answer on Stackoverflow