不知道为什么从代码块里边选不到代码块外边,所以另开一文接上面的文字。
参数化测试vodeview:
1 @RunWith(Parameterized.class) 2 public class SqrtTest { 3 public static CalculatorClass cc=new CalculatorClass(); 4 private int param; 5 private int result; 6 public SqrtTest(int param,int result){ 7 this.param=param; 8 this.result=result; 9 } 10 @Parameters 11 public static Collection data(){ 12 return Arrays.asList(new Object[][]{ 13 {4,2},{0,0},{-9,3} 14 }); 15 } 16 @Before 17 public void setUp() throws Exception { 18 cc.clear(); 19 } 20 @Test 21 public void testSqrt() { 22 cc.sqrt(param); 23 assertEquals("fucking wrong!",result, cc.getResult()); 24 25 }
打包测试codeview:
1 @RunWith(Suite.class) 2 @Suite.SuiteClasses({CalculatorClassTest.class,SqrtTest.class}) 3 public class SampledWrappedTest { 4 }