https://kotlinlang.org logo
Title
p

phil-t

06/03/2021, 9:54 AM
Hi all, I’m getting the below error when trying to set my beforeAll function to suspend
override suspend fun beforeAll() {...
, which is because I’m trying to make it call a suspend function which waits for test data to be generated (removed company names below)
Conflicting overloads: public open suspend fun beforeAll(): Unit defined in com..., public open fun beforeAll(): Unit defined in io.kotest.core.config.AbstractProjectConfig
Has anyone else had this problem?
e

Emil Kantis

06/03/2021, 10:40 AM
If you just need to bridge blocking and non-blocking code, you could invoke your suspending function in
runBlocking { }
?
p

phil-t

06/03/2021, 10:42 AM
Thanks I’ll give that a try
s

sam

06/03/2021, 12:19 PM
Does your test class extend anything other than a spec class
p

phil-t

06/03/2021, 12:25 PM
This is basically what it looks like, just extending AbstractProjectConfig
object MyConfig : AbstractProjectConfig() {
    override val globalAssertSoftly = true

    override fun beforeAll() {
        super.beforeAll()

        // Set up things here
    }
}
s

sam

06/03/2021, 12:35 PM
Ahhh you're talking about the one in project config
p

phil-t

06/03/2021, 2:17 PM
runBlocking worked perfectly, thanks for the help 🙂
s

sam

06/03/2021, 2:19 PM
So the beforeAll in project config is not suspend because it's been around since before coroutines existed
but I think for 5.0 we will make it suspendable
e

Emil Kantis

06/03/2021, 4:20 PM
What's the benefit of having it suspend? Mustn't it complete before any tests starts anyway?
s

sam

06/03/2021, 4:22 PM
allows you to do suspend stuff without requiring run blocking
😒uspend: 2
e

Emil Kantis

06/03/2021, 4:24 PM
Gotcha :)
k

Kristian

06/11/2021, 8:52 AM
That’s a welcome change, nice.