如何跳过 specs2 的实现

How to skip an implementation with specs2

在 specs2 中,给出了应该满足给定测试套件的实现列表。如何跳过当前环境中不可用的实现,但仍然显示一条消息,通知用户已跳过该给定实现的测试?

我试过了,但是执行不可用时没有显示消息

case class ImplToTest(name: String, impl: Option[Impl])

val toTest: List[ImplToTest] = ...
val testSuite: Impl => Fragment = ...

toTest.foreach { underTest =>
  s"${underTest.name}" >> underTest.map(testSuite).getOrElse(org.specs2.specification.create.DefaultFragmentFactory.text("This implementation is being skipped"))
}

类似的东西对你有用吗?

class TestSpec extends org.specs2.mutable.Specification {

  val implementations = List("now", "never", "always")

  implementations.foreach { implementation =>
    if (implementation == "never")
      s"$implementation" >> skipped("NOT NOW")
    else
      s"$implementation" >> {
        "do this" >> ok
        "do that" >> ok
      }
    br

  }
}