Top Description Fields Constructors Methods
org.assertj.core.api

public Class NotThrownAssert

extends Object
implements Descriptable<NotThrownAssert>
Class Inheritance
All Implemented Interfaces
org.assertj.core.api.Descriptable
Static Imports
org.assertj.core.api.Assertions.assertThat

Assertion class checking a 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
ThrowableTypeAssert

Field Summary

Modifier and TypeField and Description
protected Description

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public NotThrownAssert
describedAs(Description
the new description to set.
description
)

Implements org.assertj.core.api.Descriptable.describedAs.

Sets the description of the assertion that is going to be called after.
public void
isThrownBy(final ThrowableAssert.ThrowingCallable
code not throwing any exception
code
)

Assert that no exception of any type is thrown by the throwingCallable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

descriptionback to summary
protected Description description

Constructor Detail

NotThrownAssertback to summary
public NotThrownAssert()

Method Detail

describedAsback to summary
public NotThrownAssert describedAs(Description description)

Implements org.assertj.core.api.Descriptable.describedAs.

Doc from org.assertj.core.api.Descriptable.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 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.

Parameters
description:Description

the new description to set.

Returns:NotThrownAssert

this object.

Annotations
@Override
@CheckReturnValue
isThrownByback to summary
public void isThrownBy(final ThrowableAssert.ThrowingCallable code)

Assert that no exception of any type is thrown by the throwingCallable.

Example:

assertThatNoException().isThrownBy(() -> { System.out.println("OK"); });
Parameters
code:ThrowableAssert.ThrowingCallable

code not throwing any exception

Exceptions
AssertionError:
if the actual statement raised a Throwable.