-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThrowableSubject does not provide access to suppressed exceptions #717
Comments
Thanks. I am shocked that I don't recall ever hearing a request for this before. Maybe I've just forgotten, but I at least don't think it's been a common request: Inside Google, assertions on the suppressed exceptions of a We should someday have a look at what those people are doing. We have at least a couple decisions:
That expands out into various possible APIs:
Maybe enough users have only one suppressed exception that we can afford to provide Yet another possibility is to go down this road: public MultipleSuppressedExceptionComparison hasSuppressedExceptionThat() {
return new MultipleSuppressedExceptionComparison();
}
public static final class MultipleSuppressedExceptionComparison {
public void isEqualTo(Throwable expected) { ... }
public void hasMessage(String message) { ... }
// or, to support regex, contains, etc.:
public MultipleSuppressedExceptionMessageComparison hasMessageThat() { ... }
// similarly for causes, exception types, etc.
} Such a "subject" (though not a true I think I'm beginning to recall why we decided to wait for demand before pursuing this :) (On the plus side, if we found API solutions that we're happy with, I'm fairly confident that we could hack reflective or other calls to |
I'm testing a testing library which aside from hurting my brain I have a need to assert on the suppressed exceptions which are coming out attached to the exceptions my library throws.
This is a Java 7 feature, so I'm not sure how you'd go about exposing it without requiring that I do
Truth8.assertThat(throwable)
, but being able to do this is far more useful than how exactly it works. Especially given that I no longer have access to the underlyingThrowable
from the subject to do something likeassertThat(throwable.suppressed[0]).isSameInstanceAs(other)
.The text was updated successfully, but these errors were encountered: