Package org.assertj.core.api
Class AbstractSoftAssertions
- java.lang.Object
-
- org.assertj.core.api.DefaultAssertionErrorCollector
-
- org.assertj.core.api.AbstractSoftAssertions
-
- All Implemented Interfaces:
AfterAssertionErrorCollected,AssertionErrorCollector,InstanceOfAssertFactories,SoftAssertionsProvider
- Direct Known Subclasses:
BDDSoftAssertions,Java6BDDSoftAssertions,Java6JUnitBDDSoftAssertions,Java6JUnitSoftAssertions,Java6SoftAssertions,JUnitBDDSoftAssertions,JUnitJupiterBDDSoftAssertions,JUnitJupiterSoftAssertions,JUnitSoftAssertions,SoftAssertions
public abstract class AbstractSoftAssertions extends DefaultAssertionErrorCollector implements SoftAssertionsProvider, InstanceOfAssertFactories
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.assertj.core.api.SoftAssertionsProvider
SoftAssertionsProvider.ThrowingRunnable
-
-
Field Summary
Fields Modifier and Type Field Description private static AssertionErrorCreatorASSERTION_ERROR_CREATOR(package private) SoftProxiesproxies-
Fields inherited from interface org.assertj.core.api.InstanceOfAssertFactories
ARRAY, 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, SET, SHORT, SHORT_2D_ARRAY, SHORT_ARRAY, SPLITERATOR, STREAM, STRING, STRING_BUFFER, STRING_BUILDER, TEMPORAL, THROWABLE, URI_TYPE, URL_TYPE, YEAR_MONTH, ZONED_DATE_TIME
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSoftAssertions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertAll()Verifies that no soft assertions have failed.static voidassertAll(AssertionErrorCollector collector)java.util.List<java.lang.Throwable>errorsCollected()Returns a copy of list of soft assertions collected errors.<T> Tfail()Fails with an empty message to be used in code like:<T> Tfail(java.lang.String failureMessage)Fails with the given message.<T> Tfail(java.lang.String failureMessage, java.lang.Object... args)Fails with the given message built likeString.format(String, Object...).<T> Tfail(java.lang.String failureMessage, java.lang.Throwable realCause)Fails with the given message and with theThrowablethat caused the failure.<T> Tfail(java.lang.Throwable realCause)Fails with theThrowablethat caused the failure and an empty message.voidfailBecauseExceptionWasNotThrown(java.lang.Class<? extends java.lang.Throwable> throwableClass)Fails with a message explaining that aThrowableof given class was expected to be thrown but had not been.<SELF extends Assert<? extends SELF,? extends ACTUAL>,ACTUAL>
SELFproxy(java.lang.Class<SELF> assertClass, java.lang.Class<ACTUAL> actualClass, ACTUAL actual)Creates a proxied assertion class of the given type.voidshouldHaveThrown(java.lang.Class<? extends java.lang.Throwable> throwableClass)Fails with a message explaining that aThrowableof given class was expected to be thrown but had not been.-
Methods inherited from class org.assertj.core.api.DefaultAssertionErrorCollector
addAfterAssertionErrorCollected, assertionErrorsCollected, collectAssertionError, decorateErrorsCollected, getDelegate, setAfterAssertionErrorCollected, setDelegate, succeeded, wasSuccess
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.AssertionErrorCollector
assertionErrorsCollected, collectAssertionError, getDelegate, onAssertionErrorCollected, setDelegate, succeeded, wasSuccess
-
Methods inherited from interface org.assertj.core.api.SoftAssertionsProvider
assertAlso, check
-
-
-
-
Field Detail
-
proxies
final SoftProxies proxies
-
ASSERTION_ERROR_CREATOR
private static final AssertionErrorCreator ASSERTION_ERROR_CREATOR
-
-
Method Detail
-
assertAll
public static void assertAll(AssertionErrorCollector collector)
-
assertAll
public void assertAll()
Description copied from interface:SoftAssertionsProviderVerifies that no soft assertions have failed.- Specified by:
assertAllin interfaceSoftAssertionsProvider
-
proxy
public <SELF extends Assert<? extends SELF,? extends ACTUAL>,ACTUAL> SELF proxy(java.lang.Class<SELF> assertClass, java.lang.Class<ACTUAL> actualClass, ACTUAL actual)
Description copied from interface:SoftAssertionsProviderCreates a proxied assertion class of the given type. The returned value is an assertion object compatible with the supplied assertion class, but instead of throwing errors it will collect them and store.- Specified by:
proxyin interfaceSoftAssertionsProvider- Type Parameters:
SELF- The type of the assertion classACTUAL- The type of the object-under-test- Parameters:
assertClass- Class instance for the assertion type.actualClass- Class instance for the type of the object-under-test.actual- The actual object-under-test.- Returns:
- A proxied assertion class for the given object-under-test.
-
fail
@Contract("_ -> fail") public <T> T fail(java.lang.String failureMessage)
Fails with the given message.- Type Parameters:
T- dummy return value type- Parameters:
failureMessage- error message.- Returns:
- nothing, it's just to be used in
doSomething(optional.orElseGet(() -> softly.fail("boom")));. - Since:
- 2.6.0 / 3.6.0
-
fail
@Contract(" -> fail") public <T> T fail()
Fails with an empty message to be used in code like:doSomething(optional.orElseGet(() -> softly.fail()));- Type Parameters:
T- dummy return value type- Returns:
- nothing, it's just to be used in
doSomething(optional.orElseGet(() -> softly.fail()));. - Since:
- 3.26.0
-
fail
@Contract("_, _ -> fail") public <T> T fail(java.lang.String failureMessage, java.lang.Object... args)
Fails with the given message built likeString.format(String, Object...).- Type Parameters:
T- dummy return value type- Parameters:
failureMessage- error message.args- Arguments referenced by the format specifiers in the format string.- Returns:
- nothing, it's just to be used in
doSomething(optional.orElseGet(() -> softly.fail("boom")));. - Since:
- 2.6.0 / 3.6.0
-
fail
@Contract("_, _ -> fail") public <T> T fail(java.lang.String failureMessage, java.lang.Throwable realCause)
Fails with the given message and with theThrowablethat caused the failure.- Type Parameters:
T- dummy return value type- Parameters:
failureMessage- error message.realCause- cause of the error.- Returns:
- nothing, it's just to be used in
doSomething(optional.orElseGet(() -> softly.fail("boom")));. - Since:
- 2.6.0 / 3.6.0
-
fail
@Contract("_ -> fail") public <T> T fail(java.lang.Throwable realCause)
Fails with theThrowablethat caused the failure and an empty message.Example:
doSomething(optional.orElseGet(() -> softly.fail(cause)));- Type Parameters:
T- dummy return value type- Parameters:
realCause- cause of the error.- Returns:
- nothing, it's just to be used in
doSomething(optional.orElseGet(() -> softly.fail(cause)));. - Since:
- 3.26.0
-
failBecauseExceptionWasNotThrown
@Contract("_ -> fail") public void failBecauseExceptionWasNotThrown(java.lang.Class<? extends java.lang.Throwable> throwableClass)
Fails with a message explaining that aThrowableof given class was expected to be thrown but had not been.- Parameters:
throwableClass- the Throwable class that was expected to be thrown.- Throws:
java.lang.AssertionError- with a message explaining that aThrowableof given class was expected to be thrown but had not been.- Since:
- 2.6.0 / 3.6.0
- See Also:
shouldHaveThrown(Class)
-
shouldHaveThrown
@Contract("_ -> fail") public void shouldHaveThrown(java.lang.Class<? extends java.lang.Throwable> throwableClass)
Fails with a message explaining that aThrowableof given class was expected to be thrown but had not been.- Parameters:
throwableClass- the Throwable class that was expected to be thrown.- Throws:
java.lang.AssertionError- with a message explaining that aThrowableof given class was expected to be thrown but had not been.- Since:
- 2.6.0 / 3.6.0
-
errorsCollected
public java.util.List<java.lang.Throwable> errorsCollected()
Returns a copy of list of soft assertions collected errors.- Returns:
- a copy of list of soft assertions collected errors.
-
-