T
- type of throwable to be thrown.public class ThrowableTypeAssert<T extends java.lang.Throwable>
extends java.lang.Object
Throwable
type.
The class itself does not do much, it delegates the work to ThrowableAssertAlternative
after calling isThrownBy(ThrowableAssert.ThrowingCallable)
.
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.Class<? extends T> |
expectedThrowableType |
Constructor and Description |
---|
ThrowableTypeAssert(java.lang.Class<? extends T> throwableType)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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. |
final java.lang.Class<? extends T extends java.lang.Throwable> expectedThrowableType
ThrowableTypeAssert(java.lang.Class<? extends T> throwableType)
throwableType
- class representing the target (expected) exception.public ThrowableAssertAlternative<T> isThrownBy(ThrowableAssert.ThrowingCallable throwingCallable)
throwingCallable
and allow to chain assertions on the thrown exception.
Example:
assertThatExceptionOfType(IOException.class).isThrownBy(() -> { throw new IOException("boom!"); })
.withMessage("boom!");
throwingCallable
- code throwing the exception of expected typeThrowableAssertAlternative
.