Class ThrowableTypeAssert<T extends java.lang.Throwable>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.Class<? extends T> expectedThrowableType  
    • Constructor Summary

      Constructors 
      Constructor Description
      ThrowableTypeAssert​(java.lang.Class<? extends T> throwableType)
      Default constructor.
    • Field Detail

      • expectedThrowableType

        final java.lang.Class<? extends T extends java.lang.Throwable> expectedThrowableType
    • Constructor Detail

      • ThrowableTypeAssert

        ThrowableTypeAssert​(java.lang.Class<? extends T> throwableType)
        Default constructor.
        Parameters:
        throwableType - class representing the target (expected) exception.
    • Method Detail

      • isThrownBy

        public ThrowableAssertAlternative<T> isThrownBy​(ThrowableAssert.ThrowingCallable throwingCallable)
        Assert that an exception of type T is thrown by the throwingCallable and allow to chain assertions on the thrown exception.

        Example:

         assertThatExceptionOfType(IOException.class).isThrownBy(() -> { throw new IOException("boom!"); })
                                               .withMessage("boom!"); 
        Parameters:
        throwingCallable - code throwing the exception of expected type
        Returns:
        return a ThrowableAssertAlternative.