Skip to content

Commit

Permalink
Allow return values of WithAssertions#fail methods to be ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
jiri-pejchal authored and joel-costigliola committed Jun 23, 2019
1 parent a2fe4b2 commit 1160bc5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/assertj/core/api/WithAssertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ default <K, V> MapEntry<K, V> entry(final K key, final V value) {
* @return nothing, it's just to be used in doSomething(optional.orElse(() -&gt; fail("boom")));.
* @throws AssertionError with the given message.
*/
@CanIgnoreReturnValue
default <T> T fail(final String failureMessage) {
return Assertions.fail(failureMessage);
}
Expand All @@ -172,6 +173,7 @@ default <T> T fail(final String failureMessage) {
* @throws AssertionError with the given built message.
* @since 3.9.0
*/
@CanIgnoreReturnValue
default <T> T fail(String failureMessage, Object... args) {
return Assertions.fail(failureMessage, args);
}
Expand All @@ -185,6 +187,7 @@ default <T> T fail(String failureMessage, Object... args) {
* @return nothing, it's just to be used in doSomething(optional.orElse(() -&gt; fail("boom", cause)));.
* @throws AssertionError with the given message and with the {@link Throwable} that caused the failure.
*/
@CanIgnoreReturnValue
default <T> T fail(final String failureMessage, final Throwable realCause) {
return Assertions.fail(failureMessage, realCause);
}
Expand Down Expand Up @@ -1792,6 +1795,7 @@ default void setRemoveAssertJRelatedElementsFromStackTrace(final boolean removeA
* @throws AssertionError with a message explaining that a {@link Throwable} of given class was expected to be thrown but had
* not been.
*/
@CanIgnoreReturnValue
default <T> T failBecauseExceptionWasNotThrown(final Class<? extends Throwable> throwableClass) {
return Assertions.failBecauseExceptionWasNotThrown(throwableClass);
}
Expand All @@ -1806,6 +1810,7 @@ default <T> T failBecauseExceptionWasNotThrown(final Class<? extends Throwable>
* not been.
* @since 3.9.0
*/
@CanIgnoreReturnValue
default <T> T shouldHaveThrown(Class<? extends Throwable> throwableClass) {
return Assertions.shouldHaveThrown(throwableClass);
}
Expand Down

0 comments on commit 1160bc5

Please sign in to comment.