Skip to content

Instantly share code, notes, and snippets.

@Audhil
Created August 23, 2020 17:02
Show Gist options
  • Save Audhil/5e7a9efecf7e56a5296c3626fd8e1e63 to your computer and use it in GitHub Desktop.
Save Audhil/5e7a9efecf7e56a5296c3626fd8e1e63 to your computer and use it in GitHub Desktop.
instrumentation tests - Test equivalent of app module
@Module
@InstallIn(ApplicationComponent::class)
class TestAPIModule {
@Provides
fun giveRetrofitAPIService(): API =
Retrofit.Builder()
.baseUrl("http://localhost:8080/")
// .baseUrl("http://127.0.0.1:8080") // this too works
.addConverterFactory(MoshiConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
.create(API::class.java)
@Provides
fun giveTestScheduler(): TestScheduler? = null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment