public class AbstractSoftAssertions extends Object
Modifier and Type | Field and Description |
---|---|
protected org.assertj.core.api.SoftProxies |
proxies |
Constructor and Description |
---|
AbstractSoftAssertions() |
Modifier and Type | Method and Description |
---|---|
protected List<Throwable> |
decorateErrorsCollected(List<Throwable> errors)
Modifies collected errors.
|
List<Throwable> |
errorsCollected()
Returns a copy of list of soft assertions collected errors.
|
void |
fail(String failureMessage)
Fails with the given message.
|
void |
fail(String failureMessage,
Object... args)
Fails with the given message built like
String.format(String, Object...) . |
void |
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. |
<T,V> V |
proxy(Class<V> assertClass,
Class<T> actualClass,
T actual) |
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. |
boolean |
wasSuccess()
Returns the result of last soft assertion which can be used to decide what the next one should be.
|
public void fail(String failureMessage)
failureMessage
- error message.public void fail(String failureMessage, Object... args)
String.format(String, Object...)
.failureMessage
- error message.args
- Arguments referenced by the format specifiers in the format string.public void fail(String failureMessage, Throwable realCause)
Throwable
that caused the failure.failureMessage
- error message.realCause
- cause of the error.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.public List<Throwable> errorsCollected()
protected List<Throwable> decorateErrorsCollected(List<Throwable> errors)
errors
- list of errors to decoratepublic boolean wasSuccess()
Example :
Person person = ...
SoftAssertions soft = new SoftAssertions();
if (soft.assertThat(person.getAddress()).isNotNull().wasSuccess()) {
soft.assertThat(person.getAddress().getStreet()).isNotNull();
}
Copyright © 2014–2019 AssertJ. All rights reserved.