-
Notifications
You must be signed in to change notification settings - Fork 0
net.natura.testcommons.extensions.CoroutinesExtension
Lucas de Souza da Conceição edited this page Jul 10, 2020
·
4 revisions
class CoroutinesExtension : BeforeEachCallback, AfterEachCallback
A JUnit5 test extension 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:
@ExtendWith(CoroutinesExtension::class)
class MyTest {
}
See also https://gist.github.com/AniketSK/0fd48da9ed969eee307f92457115612a