单元测试
junit 简单使用:
testcase:
testcase1 @RunWith(Parameterized.class) 2 public class QuickTest extends TestCase { 3 4 @Parameters 5 public static Collection<Object[]> getParam(){ 6 return Arrays.asList(new Object[][]{ 7 {3,3}, 8 {5,5} 9 }); 10 } 11 private int input; 12 private int expect; 13 public QuickTest(int input,int expect){ 14 this.input = input; 15 this.expect = expect; 16 } 17 @Test 18 public void test() { 19 assertEquals(input,expect); 20 } 21 22 }
testsuite:
AllTests
1 @RunWith(Suite.class) 2 @SuiteClasses({ QuickTest.class }) 3 public class AllTests { 4 public static Test suite(){ 5 TestSuite ts = new TestSuite("sort test"); 6 ts.addTestSuite(QuickTest.class); 7 ts.addTestSuite(QuickTest.class); 8 return ts; 9 } 10 }

浙公网安备 33010602011771号