Hello, is using `runTest` still needed when using ...
# kotest
a
Hello, is using
runTest
still needed when using Kotest with
testCoroutineDispatcher = true
? Context : I would usually have a class with
coroutineScope: CoroutineScope
in the constructor
Copy code
class MyClass(private val coroutineScope: CoroutineScope): CoroutineScope by coroutineScope { }
then in my test I would do something like this :
Copy code
"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.
Copy code
"myTest using string spec" {
    val myClass = MyClass(this)
}
s
Kotest will handle all the coroutines for you.
Any errors and it will kill child coroutines etc.
a
That is awesome! Thanks a lot @sam