We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4a028ba commit 0489091Copy full SHA for 0489091
JUnit5-Example/src/test/java/com/journaldev/exceptions/JUnit5TestExceptions.java
@@ -0,0 +1,25 @@
1
+package com.journaldev.exceptions;
2
+
3
+import static org.junit.jupiter.api.Assertions.*;
4
5
+import org.junit.jupiter.api.Test;
6
7
+class JUnit5TestExceptions {
8
9
+ @Test
10
+ void test() {
11
+ String str = null;
12
+ assertThrows(NullPointerException.class, () -> str.length());
13
14
+ Foo foo = new Foo();
15
+ Exception exception = assertThrows(Exception.class, () -> foo.foo());
16
+ assertEquals("Exception Message", exception.getMessage());
17
+ }
18
19
+}
20
21
+class Foo {
22
+ void foo() throws Exception {
23
+ throw new Exception("Exception Message");
24
25
0 commit comments