2

Suppose I have some tests that I want to only run if some environment variable is set and the value is valid. How do I do this with Scala FunSuite?

For instance:

class Tests extends FunSuite {
  before {
    // Test if the environment variable is set and value is valid
  }

  test("foo") {
    ...
  }
}

Test foo should only run when the check in the before call succeeded. I tried to use assume but it failed with TestCanceledException.

Chao Sun
  • 655
  • 1
  • 6
  • 16
  • 2
    Using `assume` is a possible mechanism. You only need to state your assumption in the main test body. – Norwæ Nov 19 '15 at 18:20
  • An involved but possibly appropriate solution could be using ScalaTest tags, see [this example](http://stackoverflow.com/a/32460592/5519149). You would check for the presence of the environment variable in a runner script or on Jenkins. – moem Nov 19 '15 at 22:55

0 Answers0