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

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -