Should hasMessageThat() have a null check for "Causal chain is not deep enough" like hasCauseThat() does?
cpovirk opened this issue · comments
We added this way back in the original hasCauseThat()
implementation in CL 143231718:
I don't remember ever discussing whether to do it for hasMessageThat()
, too, but the case seems pretty good there, too?
And as a general rule, it's unfortunate for us to NPE for an unexpectedly null part of the value under test. (Contrast to throwing NPE on an assertion like containsExactlyElementsIn(null)
. There, NPE makes sense.)
We recently got a contribution to avoid this in some StringSubject
methods. Maybe someday we'll enable full null checking for Truth, at which point we'll be able to easily see everywhere that we need to handle null
.