Class StacktracePrintingMatcher<T extends Throwable>

java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<T>
org.junit.internal.matchers.StacktracePrintingMatcher<T>
All Implemented Interfaces:
org.hamcrest.Matcher<T>, org.hamcrest.SelfDescribing

public class StacktracePrintingMatcher<T extends Throwable> extends org.hamcrest.TypeSafeMatcher<T>
A matcher that delegates to throwableMatcher and in addition appends the stacktrace of the actual Throwable in case of a mismatch.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.hamcrest.Matcher<T>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    StacktracePrintingMatcher(org.hamcrest.Matcher<T> throwableMatcher)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    describeMismatchSafely(T item, org.hamcrest.Description description)
     
    void
    describeTo(org.hamcrest.Description description)
     
    static <T extends Exception>
    org.hamcrest.Matcher<T>
    isException(org.hamcrest.Matcher<T> exceptionMatcher)
     
    static <T extends Throwable>
    org.hamcrest.Matcher<T>
    isThrowable(org.hamcrest.Matcher<T> throwableMatcher)
     
    protected boolean
     
    private String
     

    Methods inherited from class org.hamcrest.TypeSafeMatcher

    describeMismatch, matches

    Methods inherited from class org.hamcrest.BaseMatcher

    _dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • throwableMatcher

      private final org.hamcrest.Matcher<T extends Throwable> throwableMatcher
  • Constructor Details

    • StacktracePrintingMatcher

      public StacktracePrintingMatcher(org.hamcrest.Matcher<T> throwableMatcher)
  • Method Details

    • describeTo

      public void describeTo(org.hamcrest.Description description)
    • matchesSafely

      protected boolean matchesSafely(T item)
      Specified by:
      matchesSafely in class org.hamcrest.TypeSafeMatcher<T extends Throwable>
    • describeMismatchSafely

      protected void describeMismatchSafely(T item, org.hamcrest.Description description)
      Overrides:
      describeMismatchSafely in class org.hamcrest.TypeSafeMatcher<T extends Throwable>
    • readStacktrace

      private String readStacktrace(Throwable throwable)
    • isThrowable

      public static <T extends Throwable> org.hamcrest.Matcher<T> isThrowable(org.hamcrest.Matcher<T> throwableMatcher)
    • isException

      public static <T extends Exception> org.hamcrest.Matcher<T> isException(org.hamcrest.Matcher<T> exceptionMatcher)