When using `given`, `when` and `then` of `Behaviou...
# kotlintest
j
When using
given
,
when
and
then
of
BehaviourSpec
, i noticed that given and when are actually called more times than i first expected. Once during test-discovery and then once per actual test. Thinking about it, it of course makes sense. Kotlintest needs to execute the closure to see if there are nested tests in there. Is this something I’ll have to live with or is there some trick, how i can have shared code in the given/when closure without it executing once “too often”? Here an example:
Copy code
class SomeTest : BehaviorSpec({
    Given("given"){
        println("given")

        When("when") {
            println("when")

            Then("then") {
                println("then")
            }
        }
    }
})

// Prints: given  when  given  when  then
// What I would like: given  when  then