https://kotlinlang.org logo
#kotest
Title
# kotest
a

abendt

07/01/2021, 6:04 PM
Hi everyone, i have a test that has two afterTest callbacks attached. One is via a listener that is defined in a superclass, one directly in the testclass. Is there a defined order how these callbacks are executed? what i am seeing is that the callback from the superclass comes first, the one from the testclass second. How can i achieve that the callback from the superclass comes last?
s

sam

07/03/2021, 1:17 PM
There's no specific ordering defined.
a

abendt

07/04/2021, 11:17 AM
ok, thanks let me provide some context. i recently authored a Kotest/Fluentlenium Integration. The integration manages the lifecycle of a webbrowser for use within the tests. The browser is started/stopped inside a beforeTest/afterTest callback (link ). To use the integraton your testclass needs to extend one of the provided baseclasses (example ) Now when writing actual tests it might be useful to have some shared cleanup logic that can use the browser too (see example below). With the current behavior this seems not to be possible.
Copy code
class ExampleStringSpec : FluentStringSpec({
    "Title should be correct" {
        goTo(DEFAULT_URL)
        jq("#name").fill().with("FluentLenium")
        el("#name").value() shouldBe "FluentLenium"
        window().title() shouldContain "Fluent"
    }

    afterTest {
        goTo(DEFAULT_URL) // this will fail as the browser is already closed
    }
})
Do you see any more options here to make that usecase work?