Make maven's surefire show stacktrace in conso

2019-01-21 15:33发布

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

3条回答
Bombasti
2楼-- · 2019-01-21 16:08

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.

查看更多
冷血范
3楼-- · 2019-01-21 16:21

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
查看更多
做个烂人
4楼-- · 2019-01-21 16:25

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>
..
查看更多
登录 后发表回答