public final class HasCause<T extends Throwable>
extends org.hamcrest.TypeSafeMatcher<T>
| Modifier and Type | Method and Description |
|---|---|
void |
describeTo(org.hamcrest.Description description) |
static <T extends Throwable> |
hasCause(Class<? extends Throwable> causeClass)
Creates a matcher that matches if the examined
Throwable has a cause that
is an instance of the given causeClass. |
static <T extends Throwable,C extends Throwable> |
hasCause(org.hamcrest.Matcher<C> causeMatcher)
Creates a matcher that matches if the examined
Throwable has a cause that
is matched by the specified causeMatcher. |
protected boolean |
matchesSafely(T item) |
describeMismatch, describeMismatchSafely, matchespublic static <T extends Throwable,C extends Throwable> org.hamcrest.Matcher<T> hasCause(org.hamcrest.Matcher<C> causeMatcher)
Throwable has a cause that
is matched by the specified causeMatcher.
For example:
assertThat(anException, hasCause(instanceOf(IOException.class)));T - the expected throwable typeC - the expected cause typecauseMatcher - the matcher to apply to the examined exception causepublic static <T extends Throwable> org.hamcrest.Matcher<T> hasCause(Class<? extends Throwable> causeClass)
Throwable has a cause that
is an instance of the given causeClass.
For example:
assertThat(anException, hasCause(IOException.class)));T - the expected throwable typecauseClass - the class the exception cause has to be an instance ofpublic void describeTo(org.hamcrest.Description description)
Copyright © 2013–2015. All rights reserved.