Search code examples
scalatest

What is the negative of mustBe in Scalatest


I am comfortable using mustBe in Scalatest. Eg.

A mustBe (Some(List(1)))

But how do I test something like A must not be Some(anything here, done care what it is) ?


Solution

  • Negation can be asserted on by simply adding the word not to the matcher expression, for example,

    class So1Spec extends FlatSpec with MustMatchers {
      "BeingNegative" should "assert negation" in {
        1 must not be 2
      }
    }