Package org.assertj.core.api
Class SoftThrowableAssertAlternative<ACTUAL extends Throwable>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractObjectAssert<ThrowableAssertAlternative<ACTUAL>,ACTUAL>
org.assertj.core.api.ThrowableAssertAlternative<ACTUAL>
org.assertj.core.api.SoftThrowableAssertAlternative<ACTUAL>
- All Implemented Interfaces:
Assert<ThrowableAssertAlternative<ACTUAL>,
,ACTUAL> Descriptable<ThrowableAssertAlternative<ACTUAL>>
,ExtensionPoints<ThrowableAssertAlternative<ACTUAL>,
ACTUAL>
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.- Since:
- 3.23.0
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
ConstructorDescriptionSoftThrowableAssertAlternative
(ACTUAL actual, SoftAssertionsProvider softAssertionsProvider) -
Method Summary
Modifier and TypeMethodDescriptionas
(Description description) Sets the description of the assertion that is going to be called after.protected ThrowableAssert<ACTUAL>
Methods inherited from class org.assertj.core.api.ThrowableAssertAlternative
describedAs, describedAs, havingCause, havingRootCause, withCause, withCauseExactlyInstanceOf, withCauseInstanceOf, withMessage, withMessage, withMessageContaining, withMessageContaining, withMessageContainingAll, withMessageEndingWith, withMessageEndingWith, withMessageMatching, withMessageNotContaining, withMessageNotContainingAny, withMessageStartingWith, withMessageStartingWith, withNoCause, withRootCauseExactlyInstanceOf, withRootCauseInstanceOf, withStackTraceContaining, withStackTraceContaining
Methods inherited from class org.assertj.core.api.AbstractObjectAssert
as, 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, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison
Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, 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, withThreadDumpOnError
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.assertj.core.api.Descriptable
as
-
Constructor Details
-
SoftThrowableAssertAlternative
-
-
Method Details
-
as
Description copied from interface:Descriptable
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.- Specified by:
as
in interfaceDescriptable<ACTUAL extends Throwable>
- Overrides:
as
in classThrowableAssertAlternative<ACTUAL extends Throwable>
- Parameters:
description
- the new description to set.- Returns:
this
object.- See Also:
-
getDelegate
- Overrides:
getDelegate
in classThrowableAssertAlternative<ACTUAL extends Throwable>
-