Home | History | Annotate | Download | only in junit4
      1 package test.junit4;
      2 
      3 import java.util.Arrays;
      4 import java.util.Collection;
      5 
      6 import org.junit.Assert;
      7 import org.junit.Assume;
      8 import org.junit.Ignore;
      9 import org.junit.Test;
     10 import org.junit.runner.RunWith;
     11 import org.junit.runners.Parameterized;
     12 import org.junit.runners.Parameterized.Parameters;
     13 
     14 @RunWith(Parameterized.class)
     15 public class JUnit4ParameterizedTest {
     16 
     17     public static final String[] EXPECTED = {"t2[0]", "t2[1]", "t4[0]"};
     18     public static final String[] SKIPPED = {"t3[0]", "t3[1]", "ta[0]", "ta[1]"};
     19     public static final String[] FAILED = {"t4[1]", "tf[0]", "tf[1]"};
     20 
     21     private int param;
     22 
     23     @Parameters
     24     public static Collection<Object[]> data() {
     25         return Arrays.asList(new Object[][] {{1}, {5}});
     26     }
     27 
     28     public JUnit4ParameterizedTest(int param) {
     29         this.param = param;
     30     }
     31 
     32     @Test
     33     public void t2() {
     34     }
     35 
     36     @Test
     37     @Ignore
     38     public void t3() {
     39     }
     40 
     41     @Test
     42     public void t4() {
     43         if (param == 5) {
     44             Assert.fail("a test");
     45         }
     46     }
     47 
     48     @Test
     49     public void tf() {
     50         Assert.fail("a test");
     51     }
     52 
     53     @Test
     54     public void ta() {
     55         Assume.assumeTrue(false);
     56     }
     57 }
     58