Package org.assertj.core.api
Class SoftThrowableAssertAlternative<ACTUAL extends java.lang.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 java.lang.Throwable> extends ThrowableAssertAlternative<ACTUAL>
ThrowableAssertAlternative
subclass used in soft assertions.Assertion methods for
Throwable
similar toThrowableAssert
but with assertions methods named differently to make testing code fluent (ex :withMessage
instead ofhasMessage
).
This class is linked with theSoftAssertions softly = new SoftAssertions(); softly.assertThatExceptionOfType(IOException.class) .isThrownBy(() -> { throw new IOException("boom! tcha!"); }); .withMessage("boom! %s", "tcha!");
ThrowableTypeAssert
and allow to check that an exception type is thrown by a lambda.- Since:
- 3.23.0
-
-
Field Summary
Fields Modifier and Type Field Description private ThrowableAssert<ACTUAL>
proxiedThrowableAssert
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description SoftThrowableAssertAlternative(ACTUAL actual, SoftAssertionsProvider softAssertionsProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SoftThrowableAssertAlternative<ACTUAL>
as(Description description)
Sets the description of the assertion that is going to be called after.protected ThrowableAssert<ACTUAL>
getDelegate()
-
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, withAssertionState, withComparatorByPropertyOrField, withTypeComparator
-
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
-
-
-
-
Field Detail
-
proxiedThrowableAssert
private final ThrowableAssert<ACTUAL extends java.lang.Throwable> proxiedThrowableAssert
-
-
Constructor Detail
-
SoftThrowableAssertAlternative
public SoftThrowableAssertAlternative(ACTUAL actual, SoftAssertionsProvider softAssertionsProvider)
-
-
Method Detail
-
as
public SoftThrowableAssertAlternative<ACTUAL> as(Description description)
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 java.lang.Throwable>
- Overrides:
as
in classThrowableAssertAlternative<ACTUAL extends java.lang.Throwable>
- Parameters:
description
- the new description to set.- Returns:
this
object.- See Also:
Descriptable.describedAs(Description)
-
getDelegate
protected ThrowableAssert<ACTUAL> getDelegate()
- Overrides:
getDelegate
in classThrowableAssertAlternative<ACTUAL extends java.lang.Throwable>
-
-