Package org.assertj.core.api
Class ThrowableTypeAssert<T extends java.lang.Throwable>
- java.lang.Object
-
- org.assertj.core.api.ThrowableTypeAssert<T>
-
- Type Parameters:
T- type of throwable to be thrown.
public class ThrowableTypeAssert<T extends java.lang.Throwable> extends java.lang.ObjectAssertion class checkingThrowabletype.The class itself does not do much, it delegates the work to
ThrowableAssertAlternativeafter callingisThrownBy(ThrowableAssert.ThrowingCallable).
-
-
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThrowableAssertAlternative<T>isThrownBy(ThrowableAssert.ThrowingCallable throwingCallable)Assert that an exception of type T is thrown by thethrowingCallableand allow to chain assertions on the thrown exception.
-
-
-
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 thethrowingCallableand 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.
-
-