|
|
@@ -1,11 +1,16 @@
|
|
1
|
1
|
import org.junit.Test;
|
|
2
|
2
|
import org.junit.Ignore;
|
|
|
3
|
+import org.junit.Rule;
|
|
|
4
|
+import org.junit.rules.ExpectedException;
|
|
3
|
5
|
|
|
4
|
6
|
import static org.hamcrest.CoreMatchers.*;
|
|
5
|
7
|
import static org.junit.Assert.*;
|
|
6
|
8
|
|
|
7
|
9
|
public class PrimeTest {
|
|
8
|
10
|
|
|
|
11
|
+ @Rule
|
|
|
12
|
+ public ExpectedException thrown = ExpectedException.none();
|
|
|
13
|
+
|
|
9
|
14
|
@Test
|
|
10
|
15
|
public void testFirstPrime() {
|
|
11
|
16
|
assertThat(Prime.nth(1), is(2));
|
|
|
@@ -30,8 +35,10 @@ public class PrimeTest {
|
|
30
|
35
|
}
|
|
31
|
36
|
|
|
32
|
37
|
@Ignore
|
|
33
|
|
- @Test(expected = IllegalArgumentException.class)
|
|
|
38
|
+ @Test
|
|
34
|
39
|
public void testUndefinedPrime() {
|
|
|
40
|
+ thrown.expect(IllegalArgumentException.class);
|
|
35
|
41
|
Prime.nth(0);
|
|
36
|
42
|
}
|
|
|
43
|
+
|
|
37
|
44
|
}
|