如何使用 SpecWithJUnit 将测试标记为 pendingUntilFixed

How to mark a test as pendingUntilFixed with SpecWithJUnit

import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope
import org.specs2.execute.Failure
class MyTest extends SpecWithJUnit {
  trait Context extends Scope
  "myClass" should {
    "work but not right now" in new Context {
       Failure("test fails")
    }
  }
}

在此 Specs2 示例中,如何将测试标记为待定直到修复(就像我对 SpecificationWithJUnit 所做的那样)?

您需要添加 PendingUntilFixed 特征:

import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope
import org.specs2.execute.{PendingUntilFixed, Failure}

class TestSpec extends SpecWithJUnit with PendingUntilFixed {
  trait Context extends Scope
  "myClass" should {
    "work but not right now" in new Context {
      failure("test fails")
    }.pendingUntilFixed("for now")
  }
}