The assert approach, such as
class EqualsTest extends FunSuite { test("equals") { assert(1 === 1) assert(2 === 2, "The reason is obvious") } }
Note the use of triple equivalents, which gives much better error messages than double equalities when the test fails. In addition, the second case gives a hint for printing if the test fails. It is best to use this to include some data value that would otherwise not be obvious, for example. the number of cycles when testing using a cycle.
Then there is a ShouldMatchers approach, for example
class EqualsTest extends FunSuite with ShouldMatchers { test("equals") { 1 should be (1) } }
This is often preferred because it is easy to read. However, learning how to use it is a little harder - there are a few tricks and cracks in the API. And you cannot explain the hint.
source share