I'd like to see the stacktrace of unit tests in the console. Does surefire support this?
Make maven's surefire show stacktrace in console
Asked Answered
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
This only have logger output into console, but stacktraces still goes to surefire-reports –
Kristalkristan
The answer using trimStackTrace is better! –
Uterus
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.
Yep. Not only does Maven print pages of pointless diarrhea, but it hides what you actually need to see. –
Extreme
I created an issue about this wrong default issues.apache.org/jira/browse/SUREFIRE-1457. Please comment it to help its reopening. –
Berserk
@RédaHousniAlaoui Seems they moved it to another issue for JUnit 5: issues.apache.org/jira/browse/SUREFIRE-1432 Just voted there. –
Diaconal
I set both 'trinStackTrace' and 'useFile' to false... and still I'm just getting no stack traces for my test failures :-( –
Insane
@Insane do you means stack traces has lots of line, the output show ... 26 more? –
Anacreon
Default is now
trimStackTrace=false
in 3.0.0-M6. However, we're still using 3.0.0-M5 ... :--)
–
Owlet 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
This only have logger output into console, but stacktraces still goes to surefire-reports –
Kristalkristan
The answer using trimStackTrace is better! –
Uterus
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>
...
© 2022 - 2024 — McMap. All rights reserved.