https://kotlinlang.org logo
Title
t

tim

04/11/2022, 8:45 AM
Hi ya, is there an a way to run some “after all tests / specs” logic? At the moment i’m using
Runtime.getRuntime().addShutdownHook(…)
but was curious if there’s something exposed by kotest to more easily accomplish this?
w

wasyl

04/11/2022, 9:12 AM
Yes, you can extend
AbstractProjectConfig
and override the `beforeAll`/`afterAll` methods. Some docs about project configuration class (although it doesn’t mention the before/after hooks): https://kotest.io/docs/framework/project-config.html
🙏 1
t

tim

04/11/2022, 1:15 PM
Looks to be deprecated with beforeProject/afterProject as the recoomended methods now
w

wasyl

04/11/2022, 1:16 PM
Ah might be, I still haven’t upgraded to 5.x 😬 In any case hooks are there 🙂
t

tim

04/11/2022, 1:17 PM
beforeAll/afterAll are still there just have deprecation warnings now
but this is what I was looking for so thanks for hat
👍 1
s

sam

04/13/2022, 5:59 PM
You can make project listener and add it to project config. That way you can use suspend functions. But the deprecated versions work too