Top Fields Constructors Methods
org.assertj.core.api

public abstract Class AbstractSoftAssertions

extends DefaultAssertionErrorCollector
implements SoftAssertionsProvider, InstanceOfAssertFactories
Class Inheritance
All Implemented Interfaces
org.assertj.core.api.InstanceOfAssertFactories, org.assertj.core.api.SoftAssertionsProvider, org.assertj.core.api.AssertionErrorCollector, org.assertj.core.api.AfterAssertionErrorCollected
Known Direct Subclasses
org.assertj.core.api.BDDSoftAssertions, org.assertj.core.api.Java6BDDSoftAssertions, org.assertj.core.api.SoftAssertions, org.assertj.core.api.Java6JUnitBDDSoftAssertions, org.assertj.core.api.Java6JUnitSoftAssertions, org.assertj.core.api.Java6SoftAssertions, org.assertj.core.api.JUnitBDDSoftAssertions, org.assertj.core.api.JUnitJupiterBDDSoftAssertions, org.assertj.core.api.JUnitJupiterSoftAssertions, org.assertj.core.api.JUnitSoftAssertions
Static Imports
java.lang.String.format

Field Summary

Modifier and TypeField and Description
private static final AssertionErrorCreator
pack-priv final SoftProxies

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static void
public void
assertAll()

Implements org.assertj.core.api.SoftAssertionsProvider.assertAll.

Verifies that no soft assertions have failed.
public List<Throwable>

Returns:

a copy of list of soft assertions collected errors.
errorsCollected
()

Returns a copy of list of soft assertions collected errors.

public <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail("boom")));.
fail
(String
error message.
failureMessage
)

Fails with the given message.

public <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail()));.
fail
()

Fails with an empty message to be used in code like:

 doSomething(optional.orElseGet(() -> softly.fail()));
public <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail("boom")));.
fail
(String
error message.
failureMessage
,
Object...
Arguments referenced by the format specifiers in the format string.
args
)

Fails with the given message built like String#format(String, Object...).

public <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail("boom")));.
fail
(String
error message.
failureMessage
,
Throwable
cause of the error.
realCause
)

Fails with the given message and with the Throwable that caused the failure.

public <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail(cause)));.
fail
(Throwable
cause of the error.
realCause
)

Fails with the Throwable that caused the failure and an empty message.

public void
failBecauseExceptionWasNotThrown(Class<? extends Throwable>
the Throwable class that was expected to be thrown.
throwableClass
)

Fails with a message explaining that a Throwable of given class was expected to be thrown but had not been.

public <SELF extends Assert<? extends SELF, ? extends ACTUAL>, ACTUAL> SELF
proxy(Class<SELF>
Class instance for the assertion type.
assertClass
,
Class<ACTUAL>
Class instance for the type of the object-under-test.
actualClass
,
ACTUAL
The actual object-under-test.
actual
)

Implements org.assertj.core.api.SoftAssertionsProvider.proxy.

Creates a proxied assertion class of the given type.
public void
shouldHaveThrown(Class<? extends Throwable>
the Throwable class that was expected to be thrown.
throwableClass
)

Fails with a message explaining that a Throwable of given class was expected to be thrown but had not been.

Inherited from org.assertj.core.api.DefaultAssertionErrorCollector:
addAfterAssertionErrorCollectedassertionErrorsCollectedcollectAssertionErrordecorateErrorsCollectedgetDelegatesetAfterAssertionErrorCollectedsetDelegatesucceededwasSuccess

Field Detail

ASSERTION_ERROR_CREATORback to summary
private static final AssertionErrorCreator ASSERTION_ERROR_CREATOR
proxiesback to summary
pack-priv final SoftProxies proxies

Constructor Detail

AbstractSoftAssertionsback to summary
protected AbstractSoftAssertions()

Method Detail

assertAllback to summary
public static void assertAll(AssertionErrorCollector collector)
assertAllback to summary
public void assertAll()

Implements org.assertj.core.api.SoftAssertionsProvider.assertAll.

Doc from org.assertj.core.api.SoftAssertionsProvider.assertAll.

Verifies that no soft assertions have failed.

Annotations
@Override
errorsCollectedback to summary
public List<Throwable> errorsCollected()

Returns a copy of list of soft assertions collected errors.

Returns:List<Throwable>

a copy of list of soft assertions collected errors.

failback to summary
public <T> T fail(String failureMessage)

Fails with the given message.

Parameters
<T>
dummy return value type
failureMessage:String

error message.

Returns:T

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail("boom")));.

Annotations
@CanIgnoreReturnValue
Since
2.6.0 / 3.6.0
failback to summary
public <T> T fail()

Fails with an empty message to be used in code like:

 doSomething(optional.orElseGet(() -> softly.fail()));
Parameters
<T>
dummy return value type
Returns:T

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail()));.

Annotations
@CanIgnoreReturnValue
Since
3.26.0
failback to summary
public <T> T fail(String failureMessage, Object... args)

Fails with the given message built like String#format(String, Object...).

Parameters
<T>
dummy return value type
failureMessage:String

error message.

args:Object[]

Arguments referenced by the format specifiers in the format string.

Returns:T

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail("boom")));.

Annotations
@CanIgnoreReturnValue
Since
2.6.0 / 3.6.0
failback to summary
public <T> T fail(String failureMessage, Throwable realCause)

Fails with the given message and with the Throwable that caused the failure.

Parameters
<T>
dummy return value type
failureMessage:String

error message.

realCause:Throwable

cause of the error.

Returns:T

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail("boom")));.

Annotations
@CanIgnoreReturnValue
Since
2.6.0 / 3.6.0
failback to summary
public <T> T fail(Throwable realCause)

Fails with the Throwable that caused the failure and an empty message.

Example:

 doSomething(optional.orElseGet(() -> softly.fail(cause)));
Parameters
<T>
dummy return value type
realCause:Throwable

cause of the error.

Returns:T

nothing, it's just to be used in doSomething(optional.orElseGet(() -> softly.fail(cause)));.

Annotations
@CanIgnoreReturnValue
Since
3.26.0
failBecauseExceptionWasNotThrownback to summary
public 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.

Parameters
throwableClass:Class<? extends Throwable>

the Throwable class that was expected to be thrown.

Exceptions
AssertionError:
with a message explaining that a Throwable of given class was expected to be thrown but had not been.
Since
2.6.0 / 3.6.0 Fail#shouldHaveThrown(Class) can be used as a replacement.
proxyback to summary
public <SELF extends Assert<? extends SELF, ? extends ACTUAL>, ACTUAL> SELF proxy(Class<SELF> assertClass, Class<ACTUAL> actualClass, ACTUAL actual)

Implements org.assertj.core.api.SoftAssertionsProvider.proxy.

Doc from org.assertj.core.api.SoftAssertionsProvider.proxy.

Creates 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.

Parameters
<SELF>
The type of the assertion class
<ACTUAL>
The type of the object-under-test
assertClass:Class<SELF>

Class instance for the assertion type.

actualClass:Class<ACTUAL>

Class instance for the type of the object-under-test.

actual:ACTUAL

The actual object-under-test.

Returns:SELF

A proxied assertion class for the given object-under-test.

Annotations
@Override
shouldHaveThrownback to summary
public 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.

Parameters
throwableClass:Class<? extends Throwable>

the Throwable class that was expected to be thrown.

Exceptions
AssertionError:
with a message explaining that a Throwable of given class was expected to be thrown but had not been.
Since
2.6.0 / 3.6.0