Kaynağa Gözat

Change @Test expected parameter to @Rule ExpectedException in hamming

Omerovic Dzenan 9 yıl önce
ebeveyn
işleme
542a10353c
1 değiştirilmiş dosya ile 10 ekleme ve 3 silme
  1. 10
    3
      exercises/hamming/src/test/java/HammingTest.java

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

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