public abstract class AbstractSoftAssertions extends DefaultAssertionErrorCollector implements SoftAssertionsProvider, InstanceOfAssertFactories
SoftAssertionsProvider.ThrowingRunnableARRAY, ARRAY_2D, ATOMIC_BOOLEAN, ATOMIC_INTEGER, ATOMIC_INTEGER_ARRAY, ATOMIC_INTEGER_FIELD_UPDATER, ATOMIC_LONG, ATOMIC_LONG_ARRAY, ATOMIC_LONG_FIELD_UPDATER, ATOMIC_MARKABLE_REFERENCE, ATOMIC_REFERENCE, ATOMIC_REFERENCE_ARRAY, ATOMIC_REFERENCE_FIELD_UPDATER, ATOMIC_STAMPED_REFERENCE, BIG_DECIMAL, BIG_INTEGER, BOOLEAN, BOOLEAN_2D_ARRAY, BOOLEAN_ARRAY, BYTE, BYTE_2D_ARRAY, BYTE_ARRAY, CHAR_2D_ARRAY, CHAR_ARRAY, CHAR_SEQUENCE, CHARACTER, CLASS, COLLECTION, COMPLETABLE_FUTURE, COMPLETION_STAGE, DATE, DOUBLE, DOUBLE_2D_ARRAY, DOUBLE_ARRAY, DOUBLE_PREDICATE, DOUBLE_STREAM, DURATION, FILE, FLOAT, FLOAT_2D_ARRAY, FLOAT_ARRAY, FUTURE, INPUT_STREAM, INSTANT, INT_2D_ARRAY, INT_ARRAY, INT_PREDICATE, INT_STREAM, INTEGER, ITERABLE, ITERATOR, LIST, LOCAL_DATE, LOCAL_DATE_TIME, LOCAL_TIME, LONG, LONG_2D_ARRAY, LONG_ADDER, LONG_ARRAY, LONG_PREDICATE, LONG_STREAM, MAP, MATCHER, OFFSET_DATE_TIME, OFFSET_TIME, OPTIONAL, OPTIONAL_DOUBLE, OPTIONAL_INT, OPTIONAL_LONG, PATH, PERIOD, PREDICATE, SHORT, SHORT_2D_ARRAY, SHORT_ARRAY, SPLITERATOR, STREAM, STRING, STRING_BUFFER, STRING_BUILDER, THROWABLE, URI_TYPE, URL_TYPE, ZONED_DATE_TIME| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSoftAssertions() |
| Modifier and Type | Method and Description |
|---|---|
void |
assertAll()
Verifies that no soft assertions have failed.
|
static void |
assertAll(AssertionErrorCollector collector) |
List<Throwable> |
errorsCollected()
Returns a copy of list of soft assertions collected errors.
|
<T> T |
fail(String failureMessage)
Fails with the given message.
|
<T> T |
fail(String failureMessage,
Object... args)
Fails with the given message built like
String.format(String, Object...). |
<T> T |
fail(String failureMessage,
Throwable realCause)
Fails with the given message and with the
Throwable that caused the failure. |
void |
failBecauseExceptionWasNotThrown(Class<? extends Throwable> throwableClass)
Fails with a message explaining that a
Throwable of given class was expected to be thrown
but had not been. |
<SELF extends Assert<? extends SELF,? extends ACTUAL>,ACTUAL> |
proxy(Class<SELF> assertClass,
Class<ACTUAL> actualClass,
ACTUAL actual)
Creates a proxied assertion class of the given type.
|
void |
shouldHaveThrown(Class<? extends Throwable> throwableClass)
Fails with a message explaining that a
Throwable of given class was expected to be thrown
but had not been. |
assertionErrorsCollected, collectAssertionError, decorateErrorsCollected, getDelegate, setAfterAssertionErrorCollected, setDelegate, succeeded, wasSuccessclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitassertAlso, assertSoftly, checkassertionErrorsCollected, collectAssertionError, getDelegate, onAssertionErrorCollected, setDelegate, succeeded, wasSuccessarray, array2D, atomicIntegerFieldUpdater, atomicLongFieldUpdater, atomicMarkableReference, atomicReference, atomicReferenceArray, atomicReferenceFieldUpdater, atomicStampedReference, collection, comparable, completableFuture, completionStage, future, iterable, iterator, list, map, optional, predicate, spliterator, stream, throwable, typepublic static void assertAll(AssertionErrorCollector collector)
public void assertAll()
SoftAssertionsProviderassertAll in interface SoftAssertionsProviderpublic <SELF extends Assert<? extends SELF,? extends ACTUAL>,ACTUAL> SELF proxy(Class<SELF> assertClass, Class<ACTUAL> actualClass, ACTUAL actual)
SoftAssertionsProviderproxy in interface SoftAssertionsProviderSELF - The type of the assertion classACTUAL - The type of the object-under-testassertClass - Class instance for the assertion type.actualClass - Class instance for the type of the object-under-test.actual - The actual object-under-test.public <T> T fail(String failureMessage)
T - dummy return value typefailureMessage - error message.doSomething(optional.orElseGet(() -> fail("boom")));.public <T> T fail(String failureMessage, Object... args)
String.format(String, Object...).T - dummy return value typefailureMessage - error message.args - Arguments referenced by the format specifiers in the format string.doSomething(optional.orElseGet(() -> fail("boom")));.public <T> T fail(String failureMessage, Throwable realCause)
Throwable that caused the failure.T - dummy return value typefailureMessage - error message.realCause - cause of the error.doSomething(optional.orElseGet(() -> fail("boom")));.public void failBecauseExceptionWasNotThrown(Class<? extends Throwable> throwableClass)
Throwable of given class was expected to be thrown
but had not been.throwableClass - the Throwable class that was expected to be thrown.AssertionError - with a message explaining that a Throwable of given class was expected to be thrown but had
not been.Fail.shouldHaveThrown(Class) can be used as a replacement.public void shouldHaveThrown(Class<? extends Throwable> throwableClass)
Throwable of given class was expected to be thrown
but had not been.throwableClass - the Throwable class that was expected to be thrown.AssertionError - with a message explaining that a Throwable of given class was expected to be thrown but had
not been.Copyright © 2025. All rights reserved.