Преглед изворни кода

Merge pull request #301 from odzeno/pascals-triangle

Pascals-triangle: use JUnit's @Rule feature [Fix #265]
Stuart Kent пре 9 година
родитељ
комит
dc376cacb7
1 измењених фајлова са 8 додато и 2 уклоњено
  1. 8
    2
      exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java

+ 8
- 2
exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java Прегледај датотеку

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