I use android.util.Log class for logging and debugging my code, so I end up with an Android dependency inside the domain module. This is a problem when it comes to unit testing because I have to mock the static methods of this class using PowerMock, which in my case it increases code complexity unnecessarily.
Is there any other option to log the domain module without having to mock the logger for the tests?
I use slf4j for logging in every module and just place right implementation for each of them.
For example:
data — slf4j api with slf4j-android implementation
domain — slf4j api with logback implementation
presentation — slf4j api with slf4j-android implementation
You can always use System.out.println() to avoid Android dependency.
Or, my prefered way, you can define a interface of your logger, providing it from the presentation layer with dagger, and then just inject that interface inside the domain class.
Most helpful comment
You can always use
System.out.println()to avoid Android dependency.Or, my prefered way, you can define a interface of your logger, providing it from the presentation layer with dagger, and then just inject that interface inside the domain class.