Package org.assertj.core.api
Class ThrowableTypeAssert<T extends Throwable>
java.lang.Object
org.assertj.core.api.ThrowableTypeAssert<T>
- Type Parameters:
T
- type of throwable to be thrown.
Assertion class checking
Throwable
type.
The class itself does not do much, it delegates the work to ThrowableAssertAlternative
after calling isThrownBy(ThrowableAssert.ThrowingCallable)
.
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionisThrownBy
(ThrowableAssert.ThrowingCallable throwingCallable) Assert that an exception of type T is thrown by thethrowingCallable
and allow to chain assertions on the thrown exception.
-
Field Details
-
expectedThrowableType
-
-
Constructor Details
-
ThrowableTypeAssert
Default constructor.- Parameters:
throwableType
- class representing the target (expected) exception.
-
-
Method Details
-
isThrownBy
Assert that an exception of type T is thrown by thethrowingCallable
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
.
-