1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.googlecode.catchexception.throwable.apis;
17
18 import static com.googlecode.catchexception.throwable.apis.BDDCatchThrowable.when;
19 import static com.googlecode.catchexception.throwable.apis.MyThrowableCustomAssertions.caughtThrowable;
20 import static com.googlecode.catchexception.throwable.apis.MyThrowableCustomAssertions.then;
21
22 import com.googlecode.catchexception.throwable.MyThrowable;
23
24 import org.junit.jupiter.api.Test;
25
26
27
28
29 class BDDCustomCatchThrowableTest {
30
31
32
33
34
35
36
37 @Test
38 void customException() throws Exception {
39
40 when(this::throwMyThrowable);
41
42 then(caughtThrowable()).hasErrorCode(500);
43 }
44
45
46
47
48 private void throwMyThrowable() {
49 throw new MyThrowable(500);
50 }
51
52 }