Skip to content

Commit 2c06411

Browse files
committed
Favor cause() and rootCause()
1 parent e11095d commit 2c06411

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/docs/asciidoc/user-guide/assertj-core-assertions-guide.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,14 +1298,14 @@ assertThat(throwableWithMessage).hasMessage("wrong amount 123")
12981298
[[assertj-core-throwable-cause-and-root-cause-assertions]]
12991299
===== Checking the cause and root cause
13001300

1301-
There are two approaches to check the cause and root cause, either directly or navigate to it with `getCause()` and `getRootCause()` and check it.
1301+
There are two approaches to check the cause and root cause, either directly or navigate to it with `cause()` and `rootCause()` and check it.
13021302

13031303
====== Checking the cause
13041304

1305-
You can check the cause directly if you know it but that's not always possible, in that case you can basically only check its type.
1306-
This is pretty limited in term of assertions, a better approach is to navigate to the cause with `getCause()` and take advantage of all existing exception assertions.
1305+
You can check the cause directly if you know it, but that's not always possible, and in such cases you can only check its type.
1306+
This is pretty limited in terms of assertions, a better approach is to navigate to the cause with `cause()` and take advantage of all existing exception assertions.
13071307

1308-
Direct cause assertion are limited ...
1308+
Direct cause assertions are limited ...
13091309
[source,java]
13101310
----
13111311
NullPointerException cause = new NullPointerException("boom!");
@@ -1319,11 +1319,11 @@ assertThat(throwable).hasCause(cause)
13191319
.hasCauseExactlyInstanceOf(NullPointerException.class);
13201320
----
13211321

1322-
\... but navigating to the cause allows to take advantage of all exception assertions:
1322+
\... but navigating to the cause allows taking advantage of all exception assertions:
13231323
[source,java]
13241324
----
13251325
// navigate before checking
1326-
assertThat(throwable).getCause()
1326+
assertThat(throwable).cause()
13271327
.hasMessage("boom!")
13281328
.hasMessage("%s!", "boom")
13291329
.hasMessageStartingWith("bo")
@@ -1353,7 +1353,7 @@ assertThatExceptionOfType(RuntimeException.class)
13531353
====== Checking the root cause
13541354

13551355
You can check the root cause directly with `hasRootCause`, `hasRootCauseMessage` and `hasRootCauseInstanceOf` if you have access to it but that's not always possible, this is a bit limited
1356-
in term of assertions, a better way is to navigate to the root cause with `getRootCause()` and take advantage of all existing exception assertions.
1356+
in terms of assertions, a better way is to navigate to the root cause with `rootCause()` and take advantage of all existing exception assertions.
13571357

13581358
Examples:
13591359
[source,java]
@@ -1372,7 +1372,7 @@ assertThat(throwable).hasRootCause(rootCause)
13721372
.hasRootCauseExactlyInstanceOf(NullPointerException.class);
13731373
13741374
// navigate to root cause and check
1375-
assertThat(throwable).getRootCause()
1375+
assertThat(throwable).rootCause()
13761376
.hasMessage("null!")
13771377
.hasMessage("%s!", "null")
13781378
.hasMessageStartingWith("nu")

0 commit comments

Comments
 (0)