Skip to content

Commit d692186

Browse files
Deprecate hasCauseReference(throwable) in favor of cause().isSameAs(throwable)
Fix #3715
1 parent ae98ebd commit d692186

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

assertj-core/src/main/java/org/assertj/core/api/AbstractThrowableAssert.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public SELF hasCause(Throwable cause) {
133133
*
134134
* // This assertion succeeds:
135135
* assertThat(throwable).hasCauseReference(invalidArgException);
136+
* // same assertion but more idiomatic in future versions
137+
* assertThat(throwable).cause().isSameAs(invalidArgException);
136138
*
137139
* // These assertions fail:
138140
* assertThat(throwable).hasCauseReference(new IllegalArgumentException("invalid arg"));
@@ -143,9 +145,12 @@ public SELF hasCause(Throwable cause) {
143145
* @return this assertion object.
144146
* @throws AssertionError if the actual {@code Throwable} is {@code null}.
145147
* @throws AssertionError if the actual {@code Throwable} has a cause that does not refer to the given (i.e. actual.getCause() != cause)
148+
* @deprecated use <code class='java'> cause().isSameAs(expected)</code> instead.
146149
*
147150
* @since 3.13.0
151+
* @see #cause()
148152
*/
153+
@Deprecated
149154
public SELF hasCauseReference(Throwable expected) {
150155
throwables.assertHasCauseReference(info, actual, expected);
151156
return myself;

0 commit comments

Comments
 (0)