28

I need to put one of my test cases into a "pending" state.

I would like to assing some sort of message to it that can be displayed on the output when running the test, something like JUnit with @Ignore("Pending: issue #1234 needs to be fixed").

Is there an equivalent for that with 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
    }
  }
}

Thanks in advance!

rlegendi
  • 10,466
  • 3
  • 38
  • 50

1 Answers1

44

For an individual example, I believe you can use:

class MySpec extends mutable.Specification {

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

}

I don't know if there's a way to extend this to mark all the examples in a spec as pending with the same message, as you seem to be hoping.

Robert Jack Will
  • 10,333
  • 1
  • 21
  • 29
Don Roby
  • 40,677
  • 6
  • 91
  • 113
  • 6
    You can also use `Pending("message")` instead of `failure` in the body of your example (provided that no `FailureException` is called before. In that case `pendingUntilFixed is the best approach) – Eric Jun 08 '12 at 22:39
  • Thx for the help, also @Eric for the alternative approach. – rlegendi Jun 10 '12 at 11:32
  • 2
    I think the answer is actually wrong - does not compile. The .pendingUntilFixed("message about the issue") has to be moved one line up. – Patrik Beck Oct 15 '14 at 15:11
  • If it's wrong, it may be because of recent changes in scala. This answer is 2 years old, and scala's still something of a moving target. – Don Roby Oct 15 '14 at 19:14
  • 5
    For those new to Specs2, note that tests with `pendingUntilFixed` **[will still get run](https://coderwall.com/p/rgbj2a/use-pendinguntilfixed-to-disable-specs-temporarily)**. To skip a test completely, try [`skipped`](http://stackoverflow.com/a/10974311/56285). – Jonik Oct 12 '15 at 13:55
  • If I could +1 more than once, I would for @Jonik – rbellamy Mar 30 '17 at 19:32