I have a code which returns exception object from future
val actual = doSomething(x).failed.futureValue
val expected = new SomeException()
Which is the best way to assert them
actual shouldEqual expected OR actual shouldBe expected
??
As far as I know there is no difference, but shouldEqual
is commonly used when you define your own instance of Equality
trait. So, it's up to you what method to choose.
Update
But you won't be able to compare exception because exceptions from Standard Library of Java (and Scala) don't override equals()
. But it will be OK if you use your own exceptions with overriden method equals()
.