Class ThrowableTypeAssert<T extends Throwable>

    • 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.