I'm using specs2 and my understanding is that must
and should
are equivalent (see What is the difference between should and must in scala testing?), and using one or the other is just a personal preference.
However, when comparing Strings, the following test using must
works:
import org.specs2.mutable._
class StringEqualWithMust extends Specification {
"string comp " should {
"abc" must beEqualTo("abc")
}
}
But the same test using should
won't compile:
import org.specs2.mutable._
class StringEqualWithShould extends Specification {
"string comp " should {
"abc" should beEqualTo("abc")
}
}
The compilation error is:
StringEqualWithShould.scala:7: overloaded method value should with alternatives:
[error] (fs: => org.specs2.specification.core.Fragments)(implicit p1: org.specs2.control.ImplicitParameters.ImplicitParam1)org.specs2.specification.core.Fragments <and>
[error] (f: => org.specs2.specification.core.Fragment)org.specs2.specification.core.Fragment
[error] cannot be applied to (org.specs2.matcher.BeEqualTo)
[error] "abc" should beEqualTo("abc")
[error] ^
[error] one error found
Why is there a difference between must
and should
when comparing Strings ?
I'm using sbt 0.13.8, scala 2.12.0, and specs2 3.8.6