File tree Expand file tree Collapse file tree
exercises/practice/perfect-numbers/src/test/java Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import static org .assertj .core .api .Assertions .assertThat ;
1+ import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
22import static org .junit .Assert .assertEquals ;
3- import static org .junit .Assert .assertThrows ;
43
54import org .junit .Ignore ;
65import org .junit .Test ;
@@ -79,25 +78,17 @@ public void testThatOneIsCorrectlyClassifiedAsDeficient() {
7978 @ Ignore ("Remove to run test" )
8079 @ Test
8180 public void testThatNonNegativeIntegerIsRejected () {
82- IllegalArgumentException expected =
83- assertThrows (
84- IllegalArgumentException .class ,
85- () -> new NaturalNumber (0 ));
86-
87- assertThat (expected )
88- .hasMessage ("You must supply a natural number (positive integer)" );
81+ assertThatExceptionOfType (IllegalArgumentException .class )
82+ .isThrownBy (() -> new NaturalNumber (0 ))
83+ .withMessage ("You must supply a natural number (positive integer)" );
8984 }
9085
9186 @ Ignore ("Remove to run test" )
9287 @ Test
9388 public void testThatNegativeIntegerIsRejected () {
94- IllegalArgumentException expected =
95- assertThrows (
96- IllegalArgumentException .class ,
97- () -> new NaturalNumber (-1 ));
98-
99- assertThat (expected )
100- .hasMessage ("You must supply a natural number (positive integer)" );
89+ assertThatExceptionOfType (IllegalArgumentException .class )
90+ .isThrownBy (() -> new NaturalNumber (-1 ))
91+ .withMessage ("You must supply a natural number (positive integer)" );
10192 }
10293
10394}
You can’t perform that action at this time.
0 commit comments