I'm trying to mock a Retrofit setup, specifically the response from the OkHttp client. I have the
OkHttpClient
declared as a single dependency, and the Retrofit API as another (which uses
get()
for the client). I found a mock setup for OkHttp that uses an interceptor to return a custom response, but I can't figure out how to set it up with koin. How should I do it? When I use
declareMock
I start getting errors in OkHttp..
When I copy an identical declaration from the
declareMock
to
single
in a non-test environment, everything works exactly as expected. It is only when using the
declareMock
that there is a problem. Here's the difference in object creation order:
Mock:
----
Creating client (mock)
Created client (mock)
Creating API wrapper
Creating ProPublica API
Created ProPublica API
Created API wrapper
Real:
----
Creating API wrapper
Creating ProPublica API
Creating client (real)
Created client (real)
Created ProPublica API
Created API wrapper