@Immutable public class ExceptionCauseMatcher extends org.hamcrest.TypeSafeMatcher<Throwable>
ExpectedException.expectCause(Matcher) such as:
expectedException.expect(VisitException.class);
expectedException.expectCause(hasType(IllegalArgumentException.class).andMessage("file and otherFile Components can not be the same"));
Class strongly inspired from CauseMatcher class from http://blog.codeleak.pl/2014/03/junit-expectedexception-rule-beyond.html| Modifier and Type | Method and Description |
|---|---|
ExceptionCauseMatcher |
andMessage(String expectedMessage) |
ExceptionCauseMatcher |
andNoMessage() |
void |
describeTo(org.hamcrest.Description description) |
static ExceptionCauseMatcher |
hasType(Class<? extends Throwable> type) |
protected boolean |
matchesSafely(Throwable item) |
describeMismatch, describeMismatchSafely, matchespublic static ExceptionCauseMatcher hasType(Class<? extends Throwable> type)
public ExceptionCauseMatcher andMessage(String expectedMessage)
public ExceptionCauseMatcher andNoMessage()
protected boolean matchesSafely(Throwable item)
matchesSafely in class org.hamcrest.TypeSafeMatcher<Throwable>public void describeTo(org.hamcrest.Description description)
Copyright © 2009–2016 SonarSource. All rights reserved.