How to disable test suite in ScalaTest

Viewed 22352

How to disable a test suite, i.e. all tests inside class extending FunSpec?

The only solution I'd found is to replace it with ignore in front of each test, but it is boring to do so with the dozens of tests.

6 Answers

Per scalatest docs, say if you have a test suite like this

describe ("some component") {
  it ("should do something") {
   ...
  }
  it ("should also do something else") {
   ...
  }
}

To disable just a single test, you can use the ignore() method.

describe ("some  component") {
  ignore ("should do something") {
   ...
  }
  ...
}

Use @DoNotDiscover

From the scaladoc:

import org.scalatest._

@DoNotDiscover
class SetSpec extends FlatSpec {

  "An empty Set" should "have size 0" in {
    assert(Set.empty.size === 0)
  }

  it should "produce NoSuchElementException when head is invoked" in {
    intercept[NoSuchElementException] {
      Set.empty.head
    }
  }
}
Related