TestCoroutineRule

General

Category
Free
Tag
Testing
License
Apache License, Version 2.0
Registered
Jul 7, 2019
Favorites
0
Link
https://github.com/marcinOz/TestCoroutineRule
See also
Kakao
selendroid
Gordon
RxTest
Cappuccino

Additional

Language
Kotlin
Version
1.0.2 (Aug 24, 2022)
Created
Jul 6, 2019
Updated
Aug 24, 2022 (Retired)
Owner
Marcin (marcinOz)
Contributors
Marcin (marcinOz)
marcinOziemski
2
Activity
Badge
Generate
Download
Source code

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'
}