Last active
February 26, 2021 17:30
-
-
Save oscargrgm/642f9139a99e02d88d3acce1b1e65841 to your computer and use it in GitHub Desktop.
Useful testing code from Udacity's Android Kotlin Developer Nanodegree.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Useful function to test long running operations without adding too much boilerplate. | |
*/ | |
inline fun <T> wrapEspressoIdlingResource(function: () -> T): T { | |
// Espresso does not work well with coroutines yet. See | |
// https://github.com/Kotlin/kotlinx.coroutines/issues/982 | |
EspressoIdlingResource.increment() // Set app as busy. | |
return try { | |
function() | |
} finally { | |
EspressoIdlingResource.decrement() // Set app as idle. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment