TestCoroutineRule
TestCoroutineRule library to simplify testing of coroutines, based on idea from Google IO talks: https://youtu.be/BOHK_w09pVA?t=2018.
@get:Rule
val testCoroutineRule = TestCoroutineRule()
@Test
fun `testing suspend function`() = testCoroutineRule.runBlockingTest {
val result = someSuspendFunction()
assertEquals(result, 44)
}
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency (in build.gradle under app)
dependencies {
testImplementation 'com.github.marcinOz:TestCoroutineRule:1.0.1'
}