Kaynağa Gözat

Merge pull request #296 from odzeno/HammingTest

Change @Test expected parameter to @Rule ExpectedException in hamming [Fix #262]
FridaTveit 9 yıl önce
ebeveyn
işleme
02a6a0263e

+ 10
- 3
exercises/hamming/src/test/java/HammingTest.java Dosyayı Görüntüle

3
 
3
 
4
 import org.junit.Test;
4
 import org.junit.Test;
5
 import org.junit.Ignore;
5
 import org.junit.Ignore;
6
+import org.junit.Rule;
7
+import org.junit.rules.ExpectedException;
6
 
8
 
7
 public class HammingTest {
9
 public class HammingTest {
8
     
10
     
9
 
11
 
12
+    @Rule
13
+    public ExpectedException thrown = ExpectedException.none();
14
+    
10
     @Test
15
     @Test
11
     public void testNoDifferenceBetweenIdenticalStrands() {
16
     public void testNoDifferenceBetweenIdenticalStrands() {
12
         assertThat(Hamming.compute("A", "A"), is(0));
17
         assertThat(Hamming.compute("A", "A"), is(0));
37
     }
42
     }
38
 
43
 
39
     @Ignore
44
     @Ignore
40
-    @Test(expected = IllegalArgumentException.class)
45
+    @Test
41
     public void testValidatesFirstStrandNotLonger() {
46
     public void testValidatesFirstStrandNotLonger() {
42
-        Hamming.compute("AAAG", "AAA");
47
+        thrown.expect(IllegalArgumentException.class);
48
+        Hamming.compute("AAAG", "AAA");                
43
     }
49
     }
44
 
50
 
45
     @Ignore
51
     @Ignore
46
-    @Test(expected = IllegalArgumentException.class)
52
+    @Test
47
     public void testValidatesOtherStrandNotLonger() {
53
     public void testValidatesOtherStrandNotLonger() {
54
+        thrown.expect(IllegalArgumentException.class);
48
         Hamming.compute("AAA", "AAAG");
55
         Hamming.compute("AAA", "AAAG");
49
     }
56
     }
50
 
57