如何在JaCoCo Failsafe测试执行中禁用堆栈跟踪微调



单元测试输出的stacktrace被截断,因此没有用处。我无法访问surefire报告,并且由于下面命令中设置的日志级别,大多数日志都被抑制。我也无法更改mvn命令。

如何在当前限制的情况下禁用堆栈跟踪修剪?

命令:

mvn -B -ntp -s settings.xml clean org.jacoco:jacoco-maven-plugin:0.8.7:prepare-agent test org.jacoco:jacoco-maven-plugin:0.8.7:report -Dcheckstyle.skip -Dorg.slf
4j.simpleLogger.defaultLogLevel=warn

日志输出:

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.015 s <<< FAILURE! - in ****.controller.RealmAdminControllerTest
[ERROR] test  Time elapsed: 0.013 s  <<< ERROR!
java.lang.NullPointerException
at ***.controller.RealmAdminControllerTest.test(RealmAdminControllerTest.java:18)

我已经尝试将trimStackTrace=false添加到surefire&没有任何运气的故障保护插件(单独和作为一个组(:

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<append>true</append>
<trimStackTrace>false</trimStackTrace>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>

如果您想在控制台中查看完整日志,可能还需要设置useFile参数。看看这个答案。

最新更新