are all kotest styles affected by the IDEA slowdow...
# kotest
c
are all kotest styles affected by the IDEA slowdown?
s
the IDE issues seem to be around excessive type parameters and/or lambdas. FunSpec might be the best one to use since it's the least "fancy"
c
I’m currently using minutest and my guess was that its because of all the lambdas. (https://youtrack.jetbrains.com/issue/KT-43036) so i thought maybe its a good time to try kotest in a branch. will try with funspec
i guess another problem is that all tests are defined in one huge function.
s
If you do something like
Copy code
class MyTest : FunSpec() {
  init {
   test("foo") { }
  }
}
then the number of lambdas is limited to one per test
c
maybe a quick fix is to use one class per context
btw is there support for junit rules? i currently use the coroutines timeout rule
s
Not directly, but usually it's easy to mimic, what does the coroutines timeout one do ?
c
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-debug/
Copy code
class TestRuleExample {
    @get:Rule
    public val timeout = CoroutinesTimeout.seconds(1)

    private suspend fun someFunctionDeepInTheStack() {
        withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
            delay(Long.MAX_VALUE) // Hang method
        }  
    }

    @Test
    fun hangingTest() = runBlocking {
        val job = launch {
            someFunctionDeepInTheStack()
        }
        job.join() // Join will hang
    }
}
After 1 second, test will fail with 
TestTimeoutException
 and all coroutines (
runBlocking
 and 
launch
) and their stacktraces will be dumped to the console.
👍 1
it just makes sure that coroutines test don’t hang
s
You can do,
Copy code
test("test case with timeout").config(timeout = 150.milliseconds) {
  // coroutines here
}
which will apply a timeout to the coroutine in the test
You can set the value at the test level, spec level, or globally
c
does it use coroutines-debug behind the scenes?
s
no
You can turn on the debug logging via a system property
c
thanks!
s
you're welcome 🙂