Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Created June 4, 2021 13:13
Show Gist options
  • Save manuelvicnt/d9a71e088c956fa4fc9343d931af5a5b to your computer and use it in GitHub Desktop.
Save manuelvicnt/d9a71e088c956fa4fc9343d931af5a5b to your computer and use it in GitHub Desktop.
// androidTest/projectPath/TestCoroutinesDispatchersModule.kt file
@TestInstallIn(
components = [SingletonComponent::class],
replaces = [CoroutinesDispatchersModule::class]
)
@Module
object TestCoroutinesDispatchersModule {
@DefaultDispatcher
@Provides
fun providesDefaultDispatcher(): CoroutineDispatcher =
AsyncTask.THREAD_POOL_EXECUTOR.asCoroutineDispatcher()
@IoDispatcher
@Provides
fun providesIoDispatcher(): CoroutineDispatcher =
AsyncTask.THREAD_POOL_EXECUTOR.asCoroutineDispatcher()
@MainDispatcher
@Provides
fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment