-
Notifications
You must be signed in to change notification settings - Fork 0
net.natura.testcommons.rules.CoroutinesRule
Lucas de Souza da Conceição edited this page Jul 10, 2020
·
1 revision
class CoroutinesRule : TestRule
A JUnit4 test rule to allow testing coroutines that use the main dispatcher. Without this you'd run into "java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used"
Example usage:
class MyTest {
@ExperimentalCoroutinesApi
@get:Rule
val coroutinesRule = CoroutinesRule()
}
See also https://gist.github.com/AniketSK/0fd48da9ed969eee307f92457115612a