Package org.assertj.core.api
Class AbstractSoftAssertions
java.lang.Object
org.assertj.core.api.AbstractSoftAssertions
- Direct Known Subclasses:
Java6AbstractBDDSoftAssertions
,Java6AbstractStandardSoftAssertions
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addLineNumberToErrorMessages
(List<Throwable> errors) private String
buildErrorMessageWithLineNumber
(String originalErrorMessage, StackTraceElement testStackTraceElement) private void
changeErrorMessage
(Throwable error, String errorMessageWithLineNumber) Returns a copy of list of soft assertions collected errors.void
Fails with the given message.void
Fails with the given message built likeString.format(String, Object...)
.void
Fails with the given message and with theThrowable
that caused the failure.void
failBecauseExceptionWasNotThrown
(Class<? extends Throwable> throwableClass) Fails with a message explaining that aThrowable
of given class was expected to be thrown but had not been.private StackTraceElement
getFirstStackTraceElementFromTest
(StackTraceElement[] stacktrace) <T,
V> V void
shouldHaveThrown
(Class<? extends Throwable> throwableClass) Fails with a message explaining that aThrowable
of given class was expected to be thrown but had not been.private String
simpleClassNameOf
(StackTraceElement testStackTraceElement) boolean
Returns the result of last soft assertion which can be used to decide what the next one should be.
-
Field Details
-
proxies
-
-
Constructor Details
-
AbstractSoftAssertions
public AbstractSoftAssertions()
-
-
Method Details
-
proxy
-
fail
Fails with the given message.- Parameters:
failureMessage
- error message.- Since:
- 2.6.0 / 3.6.0
-
fail
Fails with the given message built likeString.format(String, Object...)
.- Parameters:
failureMessage
- error message.- Since:
- 2.6.0 / 3.6.0
-
fail
Fails with the given message and with theThrowable
that caused the failure.- Parameters:
failureMessage
- error message.realCause
- cause of the error.- Since:
- 2.6.0 / 3.6.0
-
failBecauseExceptionWasNotThrown
Fails with a message explaining that aThrowable
of given class was expected to be thrown but had not been.- Parameters:
throwableClass
- the Throwable class that was expected to be thrown.- Throws:
AssertionError
- with a message explaining that aThrowable
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.
-
shouldHaveThrown
Fails with a message explaining that aThrowable
of given class was expected to be thrown but had not been.- Parameters:
throwableClass
- the Throwable class that was expected to be thrown.- Throws:
AssertionError
- with a message explaining that aThrowable
of given class was expected to be thrown but had not been.- Since:
- 2.6.0 / 3.6.0
-
errorsCollected
Returns a copy of list of soft assertions collected errors.- Returns:
- a copy of list of soft assertions collected errors.
-
wasSuccess
public boolean wasSuccess()Returns the result of last soft assertion which can be used to decide what the next one should be.Example :
Person person = ... SoftAssertions soft = new SoftAssertions(); if (soft.assertThat(person.getAddress()).isNotNull().wasSuccess()) { soft.assertThat(person.getAddress().getStreet()).isNotNull(); }
- Returns:
- true if the last assertion was a success.
-
addLineNumberToErrorMessages
-
addLineNumberToErrorMessage
-
buildErrorMessageWithLineNumber
private String buildErrorMessageWithLineNumber(String originalErrorMessage, StackTraceElement testStackTraceElement) -
changeErrorMessage
-
simpleClassNameOf
-
getFirstStackTraceElementFromTest
-