1

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

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

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

我似乎不能为 a 做同样的事情BehaviorSpec。我希望是这样的:

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

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

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

4

1 回答 1

0

这在 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
        }
      }
    }
  }
}
于 2019-01-17T00:38:34.397 回答