Package org.assertj.core.api
Interface SoftAssertionsProvider
-
- All Superinterfaces:
AfterAssertionErrorCollected
,AssertionErrorCollector
- All Known Subinterfaces:
AutoCloseableSoftAssertionsProvider
,BDDSoftAssertionsProvider
,Java6BDDSoftAssertionsProvider
,Java6StandardSoftAssertionsProvider
,SoftAssertionsRule
,StandardSoftAssertionsProvider
- All Known Implementing Classes:
AbstractSoftAssertions
,AutoCloseableBDDSoftAssertions
,AutoCloseableSoftAssertions
,BDDSoftAssertions
,Java6BDDSoftAssertions
,Java6JUnitBDDSoftAssertions
,Java6JUnitSoftAssertions
,Java6SoftAssertions
,JUnitBDDSoftAssertions
,JUnitJupiterBDDSoftAssertions
,JUnitJupiterSoftAssertions
,JUnitSoftAssertions
,SoftAssertions
public interface SoftAssertionsProvider extends AssertionErrorCollector
Parent interface for soft assertion implementations.- Author:
- Fr Jeremy Krieg
- See Also:
AbstractSoftAssertions
,SoftAssertions
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SoftAssertionsProvider.ThrowingRunnable
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
assertAll()
Verifies that no soft assertions have failed.default void
assertAlso(AssertionErrorCollector collector)
Add all errors ofcollector
argument to current
instance.SoftAssertionsProvider
static <S extends SoftAssertionsProvider>
voidassertSoftly(Class<S> type, Consumer<S> softly)
Use this to avoid having to call assertAll manually.default void
check(SoftAssertionsProvider.ThrowingRunnable assertion)
Catch and collect assertion errors coming from standard and custom assertions.<SELF extends Assert<? extends SELF,? extends ACTUAL>,ACTUAL>
SELFproxy(Class<SELF> assertClass, Class<ACTUAL> actualClass, ACTUAL actual)
Creates a proxied assertion class of the given type.-
Methods inherited from interface org.assertj.core.api.AssertionErrorCollector
assertionErrorsCollected, collectAssertionError, getDelegate, onAssertionErrorCollected, setDelegate, succeeded, wasSuccess
-
-
-
-
Method Detail
-
proxy
<SELF extends Assert<? extends SELF,? extends ACTUAL>,ACTUAL> SELF proxy(Class<SELF> assertClass, Class<ACTUAL> actualClass, ACTUAL actual)
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.- 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.
-
assertAll
void assertAll()
Verifies that no soft assertions have failed.- Throws:
org.opentest4j.MultipleFailuresError
- if possible or SoftAssertionError if any proxied assertion objects threw anAssertionError
-
assertAlso
default void assertAlso(AssertionErrorCollector collector)
Add all errors ofcollector
argument to current
instance.SoftAssertionsProvider
- Parameters:
collector
- the
error sourceAssertionErrorCollector
-
check
default void check(SoftAssertionsProvider.ThrowingRunnable assertion)
Catch and collect assertion errors coming from standard and custom assertions.Example :
SoftAssertions softly = new SoftAssertions(); softly.check(() -> Assertions.assertThat(…).…); softly.check(() -> CustomAssertions.assertThat(…).…); softly.assertAll();
- Parameters:
assertion
- an assertion call.
-
assertSoftly
static <S extends SoftAssertionsProvider> void assertSoftly(Class<S> type, Consumer<S> softly)
Use this to avoid having to call assertAll manually.@Test public void host_dinner_party_where_nobody_dies() { Mansion mansion = new Mansion(); mansion.hostPotentiallyMurderousDinnerParty(); SoftAssertion.assertSoftly(SoftAssertions.class, softly -> { softly.assertThat(mansion.guests()).as("Living Guests").isEqualTo(7); softly.assertThat(mansion.kitchen()).as("Kitchen").isEqualTo("clean"); softly.assertThat(mansion.library()).as("Library").isEqualTo("clean"); softly.assertThat(mansion.revolverAmmo()).as("Revolver Ammo").isEqualTo(6); softly.assertThat(mansion.candlestick()).as("Candlestick").isEqualTo("pristine"); softly.assertThat(mansion.colonel()).as("Colonel").isEqualTo("well kempt"); softly.assertThat(mansion.professor()).as("Professor").isEqualTo("well kempt"); }); }
- Type Parameters:
S
- the concrete type of soft assertions to use.- Parameters:
type
- the class object of the concrete type of soft assertions to use.softly
- the Consumer containing the code that will make the soft assertions. Takes one parameter (the SoftAssertion instance used to make the assertions).- Throws:
org.opentest4j.MultipleFailuresError
- if possible or SoftAssertionError if any proxied assertion objects threw anAssertionError
- Since:
- 3.16.0
-
-