Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between shouldBe vs shouldEqual in Scala?

When should I be using shouldBe and when should I be using shouldEqual?

port shouldEqual 8000
port shouldBe 8000
like image 327
jshah Avatar asked May 11 '17 18:05

jshah


1 Answers

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

result shouldEqual 3 // can customize equality, no parentheses required

result shouldBe 3 // cannot customize equality, so fastest to compile, no parentheses required

The first one takes an implicit Equality[T] to verify the computed value with the expected value, the second one doesn't. So if you just want to compare the port number shouldBe is sufficient.

like image 165
Harald Gliebe Avatar answered Oct 15 '22 17:10

Harald Gliebe