【问题标题】:Specs2: Ignore specification with a message?Specs2:使用消息忽略规范?
【发布时间】:2012-06-08 10:48:42
【问题描述】:

我需要将我的一个测试用例置于 “待处理” 状态。

我想给它添加一些消息,可以在运行测试时显示在输出中,比如带有@Ignore("Pending: issue #1234 needs to be fixed") 的 JUnit。

是否有与 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
    }
  }
}

提前致谢!

【问题讨论】:

    标签: scala testing specs2


    【解决方案1】:

    对于一个单独的例子,我相信你可以使用:

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

    我不知道是否有一种方法可以扩展它以将规范中的所有示例标记为待处理并带有相同的消息,正如您所希望的那样。

    【讨论】:

    • 您也可以在示例正文中使用Pending("message") 而不是failure(前提是之前没有调用FailureException。在这种情况下,`pendingUntilFixed 是最好的方法)
    • 感谢您的帮助,也感谢@Eric 的替代方法。
    • 我认为答案实际上是错误的——无法编译。 .pendingUntilFixed("message about the issue") 必须上移一行。
    • 如果错了,可能是因为最近scala的变化。这个答案已有 2 年历史,而 scala 仍然是一个移动的目标。
    • 对于 Specs2 的新手,请注意使用 pendingUntilFixed will still get run 进行测试。要完全跳过测试,请尝试skipped
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多