在 kotlintest 中的 BehaviorSpec 测试上调用配置

Calling config on a BehaviorSpec test in kotlintest

是否可以在 kotlintest 的 BehaviorSpec 中配置单独的测试用例?

对于 StringSpec 测试,可以这样做:

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

我似乎无法为 BehaviorSpec 做同样的事情。我希望是这样的:

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

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

根据 this 应该解决的问题,这已经实现了。但据我所知(使用 kotlintest 3.1.8 版)Then returns Unit...

这已在 3.2 版中修复

现在你可以做类似的事情了。

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
        }
      }
    }
  }
}