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

public Class SoftThrowableAssertAlternative<ACTUAL extends Throwable>

extends ThrowableAssertAlternative<ACTUAL extends Throwable>
Class Inheritance
Imports
org.assertj.core.description.Description

ThrowableAssertAlternative subclass used in soft assertions.

Assertion methods for java.lang.Throwable similar to ThrowableAssert but with assertions methods named differently to make testing code fluent (ex : withMessage instead of hasMessage).

 SoftAssertions softly = new SoftAssertions();

softly.assertThatExceptionOfType(IOException.class)
          .isThrownBy(() -> { throw new IOException("boom! tcha!"); });
          .withMessage("boom! %s", "tcha!"); 
This class is linked with the ThrowableTypeAssert and allow to check that an exception type is thrown by a lambda.
Since
3.23.0

Field Summary

Modifier and TypeField and Description
private final ThrowableAssert<ACTUAL>

Constructor Summary

AccessConstructor and Description
public
SoftThrowableAssertAlternative(final ACTUAL actual, SoftAssertionsProvider softAssertionsProvider)

Method Summary

Modifier and TypeMethod and Description
public SoftThrowableAssertAlternative<ACTUAL>
as(Description
the new description to set.
description
)

Overrides org.assertj.core.api.ThrowableAssertAlternative.as.

Overrides default org.assertj.core.api.Descriptable.as.

Sets the description of the assertion that is going to be called after.
protected ThrowableAssert<ACTUAL>
Inherited from org.assertj.core.api.ThrowableAssertAlternative:
describedAsdescribedAshavingCausehavingRootCausewithCausewithCauseExactlyInstanceOfwithCauseInstanceOfwithMessagewithMessagewithMessageContainingwithMessageContainingwithMessageContainingAllwithMessageEndingWithwithMessageEndingWithwithMessageMatchingwithMessageNotContainingwithMessageNotContainingAnywithMessageStartingWithwithMessageStartingWithwithNoCausewithRootCauseExactlyInstanceOfwithRootCauseInstanceOfwithStackTraceContainingwithStackTraceContaining

Field Detail

proxiedThrowableAssertback to summary
private final ThrowableAssert<ACTUAL> proxiedThrowableAssert

Constructor Detail

SoftThrowableAssertAlternativeback to summary
public SoftThrowableAssertAlternative(final ACTUAL actual, SoftAssertionsProvider softAssertionsProvider)
Annotations
@SuppressWarnings:unchecked

Method Detail

asback to summary
public SoftThrowableAssertAlternative<ACTUAL> as(Description description)

Overrides org.assertj.core.api.ThrowableAssertAlternative.as.

Overrides default org.assertj.core.api.Descriptable.as.

Doc from org.assertj.core.api.Descriptable.as.

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:SoftThrowableAssertAlternative<ACTUAL>

this object.

Annotations
@Override
getDelegateback to summary
protected ThrowableAssert<ACTUAL> getDelegate()

Overrides org.assertj.core.api.ThrowableAssertAlternative.getDelegate.

Annotations
@Override