Package org.sonar.test
Class ExceptionCauseMatcher
- java.lang.Object
-
- org.hamcrest.BaseMatcher<T>
-
- org.hamcrest.TypeSafeMatcher<java.lang.Throwable>
-
- org.sonar.test.ExceptionCauseMatcher
-
- All Implemented Interfaces:
org.hamcrest.Matcher<java.lang.Throwable>,org.hamcrest.SelfDescribing
@Immutable public class ExceptionCauseMatcher extends org.hamcrest.TypeSafeMatcher<java.lang.Throwable>Matchers designed to be used as an argument ofExpectedException.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 fromCauseMatcherclass fromhttp://blog.codeleak.pl/2014/03/junit-expectedexception-rule-beyond.html
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExceptionCauseMatcherandMessage(java.lang.String expectedMessage)ExceptionCauseMatcherandNoMessage()voiddescribeTo(org.hamcrest.Description description)static ExceptionCauseMatcherhasType(java.lang.Class<? extends java.lang.Throwable> type)protected booleanmatchesSafely(java.lang.Throwable item)-
Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, describeMismatchSafely, matches
-
-
-
-
Method Detail
-
hasType
public static ExceptionCauseMatcher hasType(java.lang.Class<? extends java.lang.Throwable> type)
-
andMessage
public ExceptionCauseMatcher andMessage(java.lang.String expectedMessage)
-
andNoMessage
public ExceptionCauseMatcher andNoMessage()
-
matchesSafely
protected boolean matchesSafely(java.lang.Throwable item)
- Specified by:
matchesSafelyin classorg.hamcrest.TypeSafeMatcher<java.lang.Throwable>
-
describeTo
public void describeTo(org.hamcrest.Description description)
-
-