It seems for latest version of ScalaTest we have two matchers one isMatchers
(ShouldMatchers before) andMustMatchers
.
What's the real difference between this two? Is that kind of style the team can choose or?
Also, any difference betweenshouldBe
and should be
The only difference is the word - quoting from the ScalaDocs for MustMatcher
:
Trait
MustMatchers
is an alternative toMatchers
that provides the exact same meaning, syntax, and behavior asMatchers
, but uses the verb must instead of should. The two traits differ only in the English semantics of the verb: should is informal, making the code feel like conversation between the writer and the reader; must is more formal, making the code feel more like a written specification.
As for should be
vs. shouldBe
... it depends on which instance of should[Be]
you are invoking. In all cases shouldBe
does one less registration step (because it skips the work that be
does). Sometimes it looks like that means fewer objects are allocated - other times, the same steps are taken, but both "should" and "be" are registered in one pass. As far as I can tell there is no difference in behavior (at least in the day-to-day of writing tests), it's just which one you prefer stylistically.