Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make maven's surefire show stacktrace in console

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

like image 784
IAdapter Avatar asked May 28 '10 11:05

IAdapter


3 Answers

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.

like image 171
h7r Avatar answered Oct 13 '22 15:10

h7r


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
like image 60
Eugene Kuleshov Avatar answered Oct 13 '22 16:10

Eugene Kuleshov


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>
..
like image 29
yegor256 Avatar answered Oct 13 '22 15:10

yegor256