1@Test
2public void test_exception_approach_1() {
3 ...
4 assertThatExceptionOfType(IOException.class)
5 .isThrownBy(() -> someBadIOOperation())
6 .withMessage("boom!");
7}
8
9@Test
10public void test_exception_approach_2() {
11 ...
12 assertThatThrownBy(() -> someBadIOOperation())
13 .isInstanceOf(Exception.class)
14 .hasMessageContaining("boom");
15}
16
17@Test
18public void test_exception_approach_3() {
19 ...
20 // when
21 Throwable thrown = catchThrowable(() -> someBadIOOperation());
22
23 // then
24 assertThat(thrown).isInstanceOf(Exception.class)
25 .hasMessageContaining("boom");
26}
27