joscha.alisch
10/25/2017, 6:42 PMgiven
, 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:
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