public class NotThrownAssert extends Object implements Descriptable<NotThrownAssert>
ThrowableAssert.ThrowingCallable throws no exception.
The class itself does not do much, it delegates the work to ThrowableAssert after calling #isThrownBy(ThrowingCallable).
ThrowableTypeAssert| Modifier and Type | Field and Description |
|---|---|
protected Description |
description |
| Constructor and Description |
|---|
NotThrownAssert() |
| Modifier and Type | Method and Description |
|---|---|
NotThrownAssert |
describedAs(Description description)
Sets the description of the assertion that is going to be called after.
|
void |
isThrownBy(ThrowableAssert.ThrowingCallable code)
Assert that no exception of any type is thrown by the
throwingCallable. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitas, as, as, describedAsprotected Description description
public void isThrownBy(ThrowableAssert.ThrowingCallable code)
throwingCallable.
Example:
assertThatNoException().isThrownBy(() -> { System.out.println("OK"); });code - code not throwing any exceptionAssertionError - if the actual statement raised a Throwable.public NotThrownAssert describedAs(Description description)
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 String by 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.
describedAs in interface Descriptable<NotThrownAssert>description - the new description to set.this object.Copyright © 2025. All rights reserved.