在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"))
}
答案 0 :(得分:1)
这样的事情对你有用吗?
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
}
}