Introduction - If you have any usage issues, please Google them yourself
JUNIT Test is a important test method for unit test to assure the programing quality. Parameterization of Junit Test can reduce the complexity and enhance the flexibility. Following is the basic steps for parameterization:
(1) import the relative class:
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters
(2) Present annotation:
@RunWith(Parameterized.class)
(3)Coding the method,such as:
@Parameters
public static Collection words(){
return Arrays.asList(new Object[][]{
{"","",2}, //测试无输入
{"2010-01-01", "2010-02-01",0} , //测试无返回结果
{"2010-07-01", "2010-07-31",2} //测试有返回结果
})
}