android - How to inject different client for retrofit when testing? -
is there way change way inject, dagger, retrofit module different client restadapter on instrumentation tests?
@provides @singleton public apiservice getapiservice() { restadapter restadapter = new restadapter.builder() .setendpoint(buildconfig.host) .build(); return restadapter.create(apiservice.class); }
but, want set new client when executing instrumentation tests.
@provides @singleton public apiservice getapiservice() { restadapter restadapter = new restadapter.builder() .setendpoint(buildconfig.host) .setclient(new mockclient()) .build(); return restadapter.create(apiservice.class); }
is there way this?
thanks
i did in project. can find sample here. app code written in kotlin , uses dagger 2. master branch contains java code , dagger 1 implementation. hope :)
Comments
Post a Comment