Sfoglia il codice sorgente

Merge pull request #302 from odzeno/series

Series: use JUnit's @Rule feature [Fix #266]
Stuart Kent 9 anni fa
parent
commit
07f6c74052
1 ha cambiato i file con 10 aggiunte e 4 eliminazioni
  1. 10
    4
      exercises/series/src/test/java/SeriesTest.java

+ 10
- 4
exercises/series/src/test/java/SeriesTest.java Vedi File

@@ -1,15 +1,20 @@
1
-
2 1
 import java.util.Arrays;
3 2
 import java.util.List;
3
+
4 4
 import org.junit.Test;
5
+import org.junit.Ignore;
6
+import org.junit.Rule;
7
+import org.junit.rules.ExpectedException;
5 8
 
6 9
 import static org.junit.Assert.assertEquals;
7 10
 import static org.junit.Assert.assertFalse;
8 11
 import static org.junit.Assert.assertNotNull;
9
-import org.junit.Ignore;
10 12
 
11 13
 public class SeriesTest {
12
-
14
+    
15
+    @Rule
16
+    public ExpectedException thrown = ExpectedException.none();
17
+    
13 18
     @Test
14 19
     public void hasDigitsShort() {
15 20
         Series sut = new Series("01234");
@@ -146,9 +151,10 @@ public class SeriesTest {
146 151
         assertEquals(expected, actual);
147 152
     }
148 153
 
149
-    @Test(expected = IllegalArgumentException.class)
154
+    @Test
150 155
     @Ignore
151 156
     public void throwsAnErrorIfNotEnoughDigitsToSlice() {
157
+        thrown.expect(IllegalArgumentException.class);
152 158
         new Series("01032987583").slices(12);
153 159
     }
154 160
 }