Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show custom failure message in Specs2 (Scala)?

For example, for code like this:

myNum must beEqualTo("SOME INTERESTING TEXT")

The message will be like the following:

java.lang.Exception: ArrayBuffer() doesn't have size 1 but size 0

Is there an elegant way to get customised message displayed here?

like image 480
Johnny Avatar asked Aug 17 '14 16:08

Johnny


1 Answers

First you can name value you're testing.

myNum aka "meaningful name" must_== expectedValue

You can also overwrite the full message.

(myNum must_== expectedValue).setMessage("Full failure message")
like image 99
cchantep Avatar answered Oct 24 '22 09:10

cchantep