Package org.assertj.core.api
Class SoftThrowableAssertAlternative<ACTUAL extends Throwable>
java.lang.Object
org.assertj.core.api.AbstractAssert<ThrowableAssertAlternative<ACTUAL>,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
ConstructorsConstructorDescriptionSoftThrowableAssertAlternative(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, withStackTraceContainingMethods 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, usingRecursiveComparisonMethods inherited from class org.assertj.core.api.AbstractAssert
actual, areEqual, asInstanceOf, asList, assertionError, asString, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, 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, usingEquals, usingEquals, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, describedAs
-
Constructor Details
-
SoftThrowableAssertAlternative
-
-
Method Details
-
as
Description copied from interface:DescriptableSets 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
Stringby 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:
asin interfaceDescriptable<ACTUAL extends Throwable>- Overrides:
asin classThrowableAssertAlternative<ACTUAL extends Throwable>- Parameters:
description- the new description to set.- Returns:
thisobject.- See Also:
-
getDelegate
- Overrides:
getDelegatein classThrowableAssertAlternative<ACTUAL extends Throwable>
-