Package org.assertj.core.api
Class NotThrownAssert
java.lang.Object
org.assertj.core.api.NotThrownAssert
- All Implemented Interfaces:
Descriptable<NotThrownAssert>
Assertion class checking a
ThrowableAssert.ThrowingCallable throws no exception.
The class itself does not do much, it delegates the work to ThrowableAssert after calling isThrownBy(ThrowingCallable).
- Since:
- 3.17.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondescribedAs(Description description) Sets the description of the assertion that is going to be called after.voidAssert that no exception of any type is thrown by thethrowingCallable.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs, describedAs
-
Field Details
-
description
-
-
Constructor Details
-
NotThrownAssert
public NotThrownAssert()
-
-
Method Details
-
isThrownBy
Assert that no exception of any type is thrown by thethrowingCallable.Example:
assertThatNoException().isThrownBy(() -> { System.out.println("OK"); });- Parameters:
code- code not throwing any exception- Throws:
AssertionError- if the actual statement raised aThrowable.
-
describedAs
Sets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
This overloaded version of "describedAs" offers more flexibility than the one taking a
Stringby allowing users to pass their own implementation of a description. For example, a description that creates its value lazily, only when an assertion failure occurs.- Specified by:
describedAsin interfaceDescriptable<NotThrownAssert>- Parameters:
description- the new description to set.- Returns:
thisobject.
-