问题
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?
回答1:
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")
来源:https://stackoverflow.com/questions/25351312/how-to-show-custom-failure-message-in-specs2-scala