File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
src/test/java/info/unterrainer/commons/jreutils Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
package info .unterrainer .commons .jreutils ;
2
2
3
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
4
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
5
+
3
6
import org .junit .jupiter .api .Test ;
4
7
5
8
public class ExceptionsTests {
6
9
7
10
@ Test
8
- public void BeforeTest () {
11
+ public void codeBeforeTest () {
9
12
try {
10
13
// Some method you don't have control over throwing an exception.
11
14
throw new IllegalArgumentException ();
@@ -15,9 +18,18 @@ public void BeforeTest() {
15
18
}
16
19
17
20
@ Test
18
- public void AfterTest () {
21
+ public void throwsExceptionWithoutSwallow () {
22
+ assertThrows (IllegalArgumentException .class , () -> {
23
+ // Some method you don't have control over throwing an exception.
24
+ throw new IllegalArgumentException ();
25
+ });
26
+ }
27
+
28
+ @ Test
29
+ public void swallowsException () {
19
30
Exceptions .swallow (() -> {
20
31
throw new IllegalArgumentException ();
21
32
}, IllegalArgumentException .class , NumberFormatException .class );
33
+ assertTrue (true );
22
34
}
23
35
}
You can’t perform that action at this time.
0 commit comments