TestCoroutineRule

Additional

Language
Kotlin
Version
1.0.1 (Jul 7, 2019)
Created
Jul 6, 2019
Updated
Jul 12, 2019
Owner
Marcin (marcinOz)
Contributor
Marcin (marcinOz)
1
Activity
Badge
Generate
Download
Source code
APK file

Blurb

TestCoroutineRule

TestCoroutineRule library to simplify testing of coroutines, based on idea from Google IO talks: https://youtu.be/BOHK_w09pVA?t=2018.

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

Step 2. Add the dependency (in build.gradle under app)

dependencies {
  testImplementation 'com.github.marcinOz:TestCoroutineRule:1.0.1'
}

allprojects { repositories { ... maven { url 'https://jitpack.io' } } }

@get:Rule val testCoroutineRule = TestCoroutineRule() @Test fun `testing suspend function`() = testCoroutineRule.runBlockingTest { val result = someSuspendFunction() assertEquals(result, 44) }