File tree Expand file tree Collapse file tree
src/test/java/com/baeldung Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 <properties >
1414 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
1515 <java .version>1.8</java .version>
16- <junit .jupiter.version>5.0.0-M3 </junit .jupiter.version>
17- <junit .platform.version>1.0.0-M3 </junit .platform.version>
18-
16+ <junit .jupiter.version>5.0.0-M4 </junit .jupiter.version>
17+ <junit .platform.version>1.0.0-M4 </junit .platform.version>
18+
1919 <maven-compiler-plugin .version>3.6.0</maven-compiler-plugin .version>
2020 <maven-surefire-plugin .version>2.19.1</maven-surefire-plugin .version>
2121 </properties >
5151 <version >${junit.jupiter.version} </version >
5252 <scope >test</scope >
5353 </dependency >
54-
5554 </dependencies >
5655</project >
Original file line number Diff line number Diff line change 11package com .baeldung ;
22
33import static org .junit .jupiter .api .Assertions .assertThrows ;
4- import static org .junit .jupiter .api .Assertions .expectThrows ;
54
65import org .junit .jupiter .api .Test ;
76
@@ -10,7 +9,7 @@ public class AssertionTest {
109 @ Test
1110 public void testConvertToDoubleThrowException () {
1211 String age = "eighteen" ;
13- expectThrows (NumberFormatException .class , () -> {
12+ assertThrows (NumberFormatException .class , () -> {
1413 convertToInt (age );
1514 });
1615
Original file line number Diff line number Diff line change 22
33import static org .junit .jupiter .api .Assertions .assertEquals ;
44import static org .junit .jupiter .api .Assertions .assertThrows ;
5- import static org .junit .jupiter .api .Assertions .expectThrows ;
65
76import org .junit .jupiter .api .Test ;
87
98public class ExceptionTest {
109
1110 @ Test
1211 void shouldThrowException () {
13- Throwable exception = expectThrows (UnsupportedOperationException .class , () -> {
12+ Throwable exception = assertThrows (UnsupportedOperationException .class , () -> {
1413 throw new UnsupportedOperationException ("Not supported" );
1514 });
1615 assertEquals (exception .getMessage (), "Not supported" );
Original file line number Diff line number Diff line change @@ -37,13 +37,13 @@ void isEmpty() {
3737 @ Test
3838 @ DisplayName ("throws EmptyStackException when popped" )
3939 void throwsExceptionWhenPopped () {
40- Assertions .expectThrows (EmptyStackException .class , () -> stack .pop ());
40+ Assertions .assertThrows (EmptyStackException .class , () -> stack .pop ());
4141 }
4242
4343 @ Test
4444 @ DisplayName ("throws EmptyStackException when peeked" )
4545 void throwsExceptionWhenPeeked () {
46- Assertions .expectThrows (EmptyStackException .class , () -> stack .peek ());
46+ Assertions .assertThrows (EmptyStackException .class , () -> stack .peek ());
4747 }
4848
4949 @ Nested
You can’t perform that action at this time.
0 commit comments