Djaytan / mc-jobs-reborn-patch-place-break

A place-break patch extension of JobsReborn plugin for Bukkit servers (Minecraft).
MIT License
5 stars 2 forks source link

test: rely on Logback instead of slf4j-nop for test logs #584

Closed Djaytan closed 7 months ago

Djaytan commented 7 months ago

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 and failsafe 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 to false, but enabling it avoid test logs being printed in the Maven execution report. Instead, logs are stored in the target/surefire-reports and target/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 by logback-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.

sonarcloud[bot] commented 7 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

github-actions[bot] commented 3 weeks ago

:tada: This PR is included in version 3.0.4 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: