Unit Testing Log Messages Made Easy

As a Java Developer, we need to cover a lot of scenarios to ensure the quality of our software and catch bugs as soon as possible when introducing a new code. For 99% of all my use cases AssertJ, Junit, Mockito, and Wiremock are sufficient enough do cover the test cases. But for the other use cases, like unit testing info, debug or warn log messages, these frameworks don’t help you out. There is also no other framework that can provide an easy to use method to capture log messages.

The answer which the community provided works well, but it is a lot of boilerplate code to just assert your log events. Even I faced the same trouble and so I wanted to make it easier for myself and share it with you! So the LogCaptor library came into life.

Source de l’article sur DZONE