规格2:忽略带有消息的规范?

rle*_*ndi 26 testing scala specs2

我需要将我的一个测试用例置于"挂起"状态.

我想给它一些消息,它可以在运行测试时显示在输出上,就像JUnit一样@Ignore("Pending: issue #1234 needs to be fixed").

与Specs2相同吗?

class MySpec extends mutable.Specification {
  args(skipAll = true) // Can I include a message here in the output somehow?

  "cool MyClass feature" should {
    "which is broken unfortunately" in {
      failure
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

提前致谢!

Don*_*oby 40

对于个别示例,我相信您可以使用:

class MySpec extends mutable.Specification {

  "cool MyClass feature" should {
    "which is broken unfortunately" in {
      failure
    }.pendingUntilFixed("message about the issue")
  }

}
Run Code Online (Sandbox Code Playgroud)

我不知道是否有一种方法可以扩展它以将规范中的所有示例标记为挂起并使用相同的消息,正如您似乎希望的那样.

  • 你也可以在你的例子的主体中使用`Pending("message")`而不是`failure`(前提是之前没有调用过'FailureException`.在这种情况下`pendingUntilFixed是最好的方法) (6认同)
  • 对于那些刚接触Specs2的人,请注意使用`pendingUntilFixed`**[仍将运行]的测试(https://coderwall.com/p/rgbj2a/use-pendinguntilfixed-to-disable-specs-temporarily)**.要完全跳过测试,请尝试[`skipped`](http://stackoverflow.com/a/10974311/56285). (4认同)
  • 我认为答案实际上是错误的 - 不编译..pendingUntilFixed("关于问题的消息")必须向上移动一行. (2认同)