Wesley Hartford
11/10/2023, 10:45 PMafterAny gets called for the last test and the test container, the afterContainer gets called, but the afterSpec function does not get called. Does anyone know what happens between afterContainer and afterSpec that could cause the test execution to hang? Thanks.LeoColman
11/10/2023, 11:01 PMWesley Hartford
11/10/2023, 11:23 PMafterProject happens after afterSpec, I've added an afterProject log to my test and it does not get called.sam
11/11/2023, 12:31 AMWesley Hartford
11/11/2023, 12:38 AMbeforeSpec, I launch a coroutine in GlobalScope which continues in the background (the tests interact with services running there). That launched job is cancelled in an afterSpec. The test hangs before that afterSpec is called.sam
11/11/2023, 12:39 AMsam
11/11/2023, 12:39 AMWesley Hartford
11/11/2023, 12:40 AMsam
11/11/2023, 12:40 AMWesley Hartford
11/11/2023, 12:41 AMsam
11/11/2023, 12:42 AMWesley Hartford
11/11/2023, 12:45 AMafterSpec?sam
11/11/2023, 12:46 AMsam
11/11/2023, 12:46 AMWesley Hartford
11/11/2023, 12:48 AMWesley Hartford
11/11/2023, 12:49 AMsam
11/11/2023, 12:49 AMsam
11/11/2023, 12:49 AMWesley Hartford
11/11/2023, 12:56 AMcoroutineContext passed to the launch function. I had been passing a modified version of the currentCoroutineContext(), but with no context argument, the test completes.Wesley Hartford
11/11/2023, 1:10 AMsam
11/11/2023, 1:11 AMWesley Hartford
11/11/2023, 1:12 AMWesley Hartford
11/11/2023, 1:13 AMsam
11/11/2023, 1:13 AMWesley Hartford
11/11/2023, 1:13 AMsam
11/11/2023, 1:13 AMOliver.O
11/11/2023, 1:24 AMOliver.O
11/11/2023, 1:34 AMWesley Hartford
11/11/2023, 1:56 AMclass KotestHangBeforeAfterSpec : FunSpec(
{
lateinit var job: Job
beforeSpec {
job = GlobalScope.launch(currentCoroutineContext()) { delay(Duration.INFINITE) }
}
afterSpec {
job.cancel()
}
test("always pass") {
assert(true)
}
}
)Wesley Hartford
11/11/2023, 1:57 AMcurrentCoroutineContext() argument to the launch function fixes the problem.Wesley Hartford
11/11/2023, 2:04 AMsam
11/11/2023, 2:04 AMsam
11/11/2023, 2:04 AMWesley Hartford
11/11/2023, 2:05 AMsam
11/11/2023, 2:05 AMWesley Hartford
11/11/2023, 2:05 AMWesley Hartford
11/11/2023, 5:25 AMOliver.O
11/11/2023, 9:29 AMOliver.O
11/11/2023, 4:50 PMbecause we have various dynamic ways of determining if a test is enabledhttps://github.com/kotest/kotest/issues/3534#issuecomment-1656845546