Matchers
Expressive assertions.
What are Matchers?
ScalaTest matchers provide an expressive, English-like syntax for assertions. Instead of assert(x == 3), you write x shouldBe 3, producing readable tests and clear failure messages.
Mixing in Matchers
Mix the Matchers trait into your spec to unlock the DSL. It combines with any testing style.
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class DemoSpec extends AnyFlatSpec with Matchers {
"A value" should "equal itself" in {
val x = 3
x shouldBe 3
}
}