How to show custom failure messages in ScalaTest?
Does anyone know how to show a custom failure message in ScalaTest? For example: NumberOfElements() should equal (5) Shows the following message when it fails: 10 did not equal 5 But i want more descriptive message like: NumberOfElements should be 5. You're the first to ask for such a feature. One way to achieve this is with withClue. Something like: withClue("NumberOfElements: ") { NumberOfElements() should be (5) } That should get you this error message: NumberOfElements: 10 was not equal to 5 If you want to control the message completely you can write a custom matcher. Or you could use an