Search code examples
scalatestingscalatestspecs2

How to use the === syntax from Specs2 in ScalaTest


I really like this syntax from Specs2 in order to test for equality:

1 + 1 === 2

instead of:

assert(1+1 == 2)

or the English-like synonims.

Can this syntax also be used in ScalaTest?

Here is the list of matchers that ScalaTest and Specs2 supports.


Solution

  • It is described as supported in the docs of ScalaTest, so yes:

    http://www.scalatest.org/user_guide/using_matchers#checkingEqualityWithMatchers

    result should === (3)   // can customize equality and enforce type constraints