Last Updated: February 25, 2016
·
879
· bjpbakker

scalatest.FunSpec: ignore with xit

To ignore a spec for a few runs (normally only to refactor before I can actually implement the spec) Scalatest allows you to 'ignore' the test. Consider the following example spec.

class SomeSpec extends FunSpec {
  describe("Something") {
    it ("does something") { .. }
  }
}

To temporarily ignore the spec you can replace 'it' with 'ignore'

describe("Something") {
  ignore ("does something") { .. }
}

That's okay, but it gets a little annoying. Especially since it can also be done with a single key character (I'm not talking vim or emacs keystrokes here).

At least a number of other spec libraries allow you to ignore a spec by putting an 'x' in front of it, i.e. by using 'xit' instead of 'it'. You can do the same with Scalatest by delegating 'xit' to the standard ignore.

def xit(description: String, tags: scalatest.Tag*)(fn: => Unit) = ignore(description, tags:_*)(fn)