Last active
July 27, 2019 10:05
-
-
Save Audhil/43d16e18c06f794590d285029c3d2e85 to your computer and use it in GitHub Desktop.
Dagger2 Module class - https://android.jlelse.eu/instrumentation-testing-with-dagger2-retrofit2-mockwebserver-android-4cca7cb7373c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
class TestApplicationModule(application: GitHubDelegate) : ApplicationModule(application) { | |
@Singleton | |
@Provides | |
fun giveRetrofit(okHttpClient: OkHttpClient): Retrofit = | |
Retrofit.Builder() | |
.baseUrl("http://localhost:8080/") | |
.addConverterFactory(GsonConverterFactory.create(GsonBuilder().create())) | |
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | |
.client(okHttpClient) | |
.build() | |
@Singleton | |
@Provides | |
fun giveMockWebServer(): MockWebServer = MockWebServer() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment