September 2018
Intermediate to advanced
398 pages
9h 43m
English
The Equality type class is used by ScalaTest unit tests whenever you write assertions, such as the following:
actual shouldBe expectedactual should === (expected)
Most of the time, you will not have to worry about it; the default instance compares types by using the equals method. However, whenever you compare double values or classes that contain double attributes, it becomes necessary to provide a different Equality instance.
Consider the following unit test:
class EqualitySpec extends WordSpec with Matchers with TypeCheckedTripleEquals{ "Equality" should { "allow to compare two Doubles with a tolerance" in { 1.6 + 1.8 should === (3.4) } } }
This test should pass, right? Wrong! Try to run it; the assertion fails, ...
Read now
Unlock full access