单元测试

junit 简单使用:

testcase:

testcase
 1 @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 }

 

 

posted on 2013-01-05 18:52  幸运的小鸟  阅读(90)  评论(0)    收藏  举报

导航