Calling config on a BehaviorSpec test in kotlintest

440 views Asked by At

Is it possible to configure individual test cases in a BehaviorSpec in kotlintest?

For StringSpec tests it is possible to do like so:

class MyTest : StringSpec({
    "this is a test".config(...) {}
})

I can't seem to do the same for a BehaviorSpec. I'd expect something like:

class MyTest : BehaviorSpec({
    Given("a foo") {
        When("baring") {
            Then("bazzing") {

            }.config(...)
        }
    }
})

According to this supposedly solved issue, this is already implemented. But as far as I can see (using version 3.1.8 of kotlintest) Then returns Unit...

1

There are 1 answers

1
sksamuel On BEST ANSWER

This is fixed in release 3.2

Now you can do something like.

class BehaviorSpecExample : AbstractBehaviorSpec() {

  init {
    given("a sheet of string cells 4x4") {
      `when`("get existing cell by reference (like A1 or B2)") {
        then("should contain its value").config(invocations = 3) {
          // test here
        }
      }
    }
  }
}