You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background: I often use assertThat (catchException (...)).isInstanceOf (...) instead of assertThatThrowBy ... or something similar. I guess it's a matter of taste what to prefer. I have noticed that isInstanceOf() issues a pretty confusing failure message when nothing is actually thrown, i.e. when catchException() returns null.
Background: I often use
assertThat (catchException (...)).isInstanceOf (...)
instead ofassertThatThrowBy ...
or something similar. I guess it's a matter of taste what to prefer. I have noticed thatisInstanceOf()
issues a pretty confusing failure message when nothing is actually thrown, i.e. whencatchException()
returnsnull
.To illustrate, when I run this code:
I get this failure message:
In comparison, when the tested object is not
null
, but of a wrong class, failure message is much more clear. For example:gives me this:
Suggestion
Rephrase the
null
-case message somewhat like this:The text was updated successfully, but these errors were encountered: