Closed Djaytan closed 7 months ago
Issues
0 New issues
Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
:tada: This PR is included in version 3.0.4 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
By default, the Maven execution report contains the test logs which can make a lot harder to read the Maven report. As a solution to this problem, the
slf4j-nop
dependency has been used to prevent tests from printing any logs, and it worked well.However, that's not a good solution when comes debugging time where we want to have access to these logs for helping us. That's why an alternative solution was welcome and finally one has been found.
Since our main need is to remove the test logs from the Maven execution report, we can search on the
surefire
andfailsafe
Maven plugins side since they are the ones in charge of executing the tests. And finally we can found the following property:redirectTestOutputToFile
(https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#redirectTestOutputToFile). By default its value is turned tofalse
, but enabling it avoid test logs being printed in the Maven execution report. Instead, logs are stored in thetarget/surefire-reports
andtarget/failsafe-reports
in a file named<test_name>-output.txt
(e.g.fr.djaytan.mc.jrppb.core.config.ConfigApiTest-output.txt
). That's exactly what we want!Now that the right solution matching exactly our needs has been identified, we need to print back test logs, hence the replacement of
slf4j-nop
bylogback-classic
. After having made this change, we could observe that the Maven execution report still not print any test logs, as expected. Perfect! Job done.In the end, what's really matter is the possibility to see the logs being printed in the test execution output through a custom test reporter like the IntelliJ one. This is a lot more convenient for analysing logs of a specific case than it is the case through Maven. Furthermore, we can benefit of other solutions like the debugger from the IDE, making the debugging experience a lot easier for the developer.