I would like to display the Exception message thrown in scala test.
" iWillThrowCustomException Method Failure test.
" should "Fail, Reason: Reason for failing. " in {
evaluating {
iWillThrowCustomException();
} should produce [CustomException]
}
If CustomExeption will throw different types of messages for differnt inputs , say
(for -ve amount – Amount is less than zero, for chars in amount – Invalid amount),
how to display the message which is thrown in the block, becuase it will through
the CustomException and it will show Test Success, but for which senario it has thrown the error
evaluatingalso returns an exception so you can inspect it or print the message. Here is example from the ScalaDoc:As far as I know, you can’t include exception message in the test name.
What you can do, is to add additional information about test with
info():This will be shown in the test results as nested message. You can find more info about this in ScalaDoc.