Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote android.util.Log references to use this library in JUnit tests without Robolectric #33

Open
muthuraj57 opened this issue Jul 14, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@muthuraj57
Copy link

Is your feature request related to a problem? Please describe.
Mockinizer internally uses android.util.log in DebugLogger which makes it impossible to use this library in JUnit tests without using Robolectric.

Describe the solution you'd like
Remove android.util.Log references from this library.

Describe alternatives you've considered
There is an option to provide a custom logger, but this provision is not there for all the places where DebugLogger is used.
mockinize method accepts a custom logger and I passed one there.
Still I got this error on using this library in JUnit test.

Method d in android.util.Log not mocked. See http://g.co/androidstudio/not-mocked for details.
java.lang.RuntimeException: Method d in android.util.Log not mocked. See http://g.co/androidstudio/not-mocked for details.
	at android.util.Log.d(Log.java)
	at com.appham.mockinizer.DebugLogger.d(Logger.kt:7)
	at com.appham.mockinizer.RequestFilter$Companion.from(RequestFilter.kt:36)
	at com.appham.mockinizer.MockinizerInterceptor$intercept$1.invoke(MockinizerInterceptor.kt:20)
	at com.appham.mockinizer.MockinizerInterceptor$intercept$2.invoke(MockinizerInterceptor.kt:42)
	at com.appham.mockinizer.MockinizerInterceptor.intercept(MockinizerInterceptor.kt:56)

MockinizerInterceptor instance is created internally and it uses DebugLogger and there is no way to provide a custom logger there as the dependencies required to create this interceptor are not public.

A simple solution would be to use println instead of android.util.log in DebugLogger.

@muthuraj57 muthuraj57 added the enhancement New feature or request label Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant