what is the correct way to use suspend functions i...
# coroutines
d
what is the correct way to use suspend functions inside
androidTest
source set Currently I'm testing Room DB Dao in Android and writing test like this
Copy code
runBlocking {
    movieDao.insertCategory(popularMovies)
}
I think that there might be a better way to write test for such scenario because if I have 20 test than I have to write
runBlocking
20 times
j
Until Coroutines 1.6 there is no alternative, only
runBlockingTest
, but you would have the same problem
With 1.6 I think
suspend
test functions are allowed
j
@Javier I believe the decision that was taken on this topic is that it is sufficient to implement it on library side and would be too complex to include as a language feature. So you'll have to use
runBlockingTest
even in the future AFAIU. The biggest problem currently is that it's only available on JVM platform at the moment because the
kotlinx-coroutines-test
library is not multiplatform yet.
j
Where there is more info about that? I think it has not to be resolved inside Kotlin itself, just the test framework library, no?