public class SoftThrowableAssertAlternative<ACTUAL extends Throwable> extends ThrowableAssertAlternative<ACTUAL>
ThrowableAssertAlternative subclass used in soft assertions.
Assertion methods for 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.actual, info, myself, objects, throwUnsupportedExceptionOnEquals| Constructor and Description |
|---|
SoftThrowableAssertAlternative(ACTUAL actual,
SoftAssertionsProvider softAssertionsProvider) |
| Modifier and Type | Method and Description |
|---|---|
SoftThrowableAssertAlternative<ACTUAL> |
as(Description description)
Sets the description of the assertion that is going to be called after.
|
protected ThrowableAssert<ACTUAL> |
getDelegate() |
describedAs, describedAs, havingCause, havingRootCause, withCause, withCauseExactlyInstanceOf, withCauseInstanceOf, withMessage, withMessage, withMessageContaining, withMessageContaining, withMessageContainingAll, withMessageEndingWith, withMessageEndingWith, withMessageMatching, withMessageNotContaining, withMessageNotContainingAny, withMessageStartingWith, withMessageStartingWith, withNoCause, withRootCauseExactlyInstanceOf, withRootCauseInstanceOf, withStackTraceContaining, withStackTraceContainingas, doesNotReturn, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveComparison, usingRecursiveComparisonareEqual, asInstanceOf, asList, assertionError, asString, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitaspublic SoftThrowableAssertAlternative(ACTUAL actual, SoftAssertionsProvider softAssertionsProvider)
public SoftThrowableAssertAlternative<ACTUAL> as(Description description)
DescriptableYou 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.
as in interface Descriptable<ThrowableAssertAlternative<ACTUAL extends Throwable>>as in class ThrowableAssertAlternative<ACTUAL extends Throwable>description - the new description to set.this object.Descriptable.describedAs(Description)protected ThrowableAssert<ACTUAL> getDelegate()
getDelegate in class ThrowableAssertAlternative<ACTUAL extends Throwable>Copyright © 2025. All rights reserved.