Sfoglia il codice sorgente

Merge pull request #301 from odzeno/pascals-triangle

Pascals-triangle: use JUnit's @Rule feature [Fix #265]
Stuart Kent 9 anni fa
parent
commit
dc376cacb7

+ 8
- 2
exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java Vedi File

1
 import org.junit.Test;
1
 import org.junit.Test;
2
 import org.junit.Ignore;
2
 import org.junit.Ignore;
3
+import org.junit.Rule;
4
+import org.junit.rules.ExpectedException;
5
+
3
 
6
 
4
 import static org.junit.Assert.assertArrayEquals;
7
 import static org.junit.Assert.assertArrayEquals;
5
 import static org.junit.Assert.assertEquals;
8
 import static org.junit.Assert.assertEquals;
6
 
9
 
7
 public class PascalsTriangleTest {
10
 public class PascalsTriangleTest {
8
 
11
 
9
-
12
+    @Rule
13
+    public ExpectedException thrown = ExpectedException.none();
14
+    
10
     @Test
15
     @Test
11
     public void testTriangleWithFourRows() {
16
     public void testTriangleWithFourRows() {
12
         int[][] expectedOutput = new int[][]{
17
         int[][] expectedOutput = new int[][]{
72
     }
77
     }
73
 
78
 
74
     @Ignore
79
     @Ignore
75
-    @Test(expected = IllegalArgumentException.class)
80
+    @Test
76
     public void testValidatesNotNegativeRows() {
81
     public void testValidatesNotNegativeRows() {
82
+        thrown.expect(IllegalArgumentException.class);
77
         PascalsTriangle.computeTriangle(-1);
83
         PascalsTriangle.computeTriangle(-1);
78
     }
84
     }
79
 }
85
 }