public final class HasMessage<T extends Throwable>
extends org.hamcrest.TypeSafeMatcher<T>
| Modifier and Type | Method and Description |
|---|---|
void |
describeTo(org.hamcrest.Description description) |
static <T extends Throwable> |
hasMessage(org.hamcrest.Matcher<String> messageMatcher)
Creates a matcher that matches if the examined
Throwable has a message that
is matched by the specified messageMatcher. |
static <T extends Throwable> |
hasMessage(String message)
Creates a matcher that matches if the examined
Throwable has a message that
is equal to the given message. |
protected boolean |
matchesSafely(T throwable) |
describeMismatch, describeMismatchSafely, matchespublic static <T extends Throwable> org.hamcrest.Matcher<T> hasMessage(org.hamcrest.Matcher<String> messageMatcher)
Throwable has a message that
is matched by the specified messageMatcher.
For example:
assertThat(anException, hasCause(startsWith("IOException occurred")));T - the expected throwable typemessageMatcher - the matcher to apply to the examined exception messagepublic static <T extends Throwable> org.hamcrest.Matcher<T> hasMessage(String message)
Throwable has a message that
is equal to the given message.
For example:
assertThat(anException, hasMessage("file not writable")));T - the expected throwable typemessage - the message that has to be equal to the exception messagepublic void describeTo(org.hamcrest.Description description)
Copyright © 2013–2015. All rights reserved.