Alexandre Brown
06/07/2022, 1:16 PMrunTest
still needed when using Kotest with testCoroutineDispatcher = true
?
Context : I would usually have a class with coroutineScope: CoroutineScope
in the constructor
class MyClass(private val coroutineScope: CoroutineScope): CoroutineScope by coroutineScope { }
then in my test I would do something like this :
"myTest using string spec" {
runTest {
val myClass = MyClass(this)
}
}
So that it uses the Coroutine scope from runTest
.
I see that StringSpec
has a test scope so that I can do the same but without wrapping my test with runTest
, is it safe to do so? I want to ensure the are no coroutines leaks between test to avoid flaky tests.
"myTest using string spec" {
val myClass = MyClass(this)
}
sam
06/07/2022, 8:43 PMAlexandre Brown
06/07/2022, 8:43 PM