In many cases we want to test if our application logging is implemented in proper way.
This is another easy way to testing what our application logs when we use
slf4j-mock we can mock all logger and assert it as we do with other mocked method.
Feature of library:
- this binding support for easy create
Mockito mock for
- call to
Logger can be delegated to instance of
so we can create standard
- support for testing and mocking
- light transitive dependencies - only
- support testing in parallel in multi thread
- all the Magic are done by
Mockito plugins, so you don’t need to directly use class from this library
- ease use
First we should add
slf4j-mock binding as dependency to our project,
we must remember that we can have only one slf4j binding on classpath.
Now we have class which does some logging action
And finally we write test for it
As we see thanks mocking slf4j logger we can prepare test for many scenario which we want.
More examples are available at project page: https://www.simplify4u.org/slf4j-mock/
In case of new requirement, bugs or other feedback we invite to github project
slf4j mock testing