文件名称:testsrc
- 所属分类:
- JSP源码/Java
- 资源属性:
- [Java] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 3kb
- 下载次数:
- 0次
- 提 供 者:
- 徐**
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
利用JUNIT实现单元测试,是提高单元测试效率和质量的重要方法 而参数化的单元测试对于测试覆盖型\案例灵活性具有重要作用. 参数化测试的基本步骤包括:
(1) 引用参数化的相关类,如:
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters
(2) 在测试类中增加注解:
@RunWith(Parameterized.class)
(3)增加参数方法:
@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} //测试有返回结果
})
}-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} //测试有返回结果
})
}
(1) 引用参数化的相关类,如:
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters
(2) 在测试类中增加注解:
@RunWith(Parameterized.class)
(3)增加参数方法:
@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} //测试有返回结果
})
}-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} //测试有返回结果
})
}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
testsrc\com\bocsoft\cibs\cash\fake\AllTests1.java
.......\...\.......\....\....\....\BfwTest.java
.......\...\.......\....\....\....\DummyContext.java
.......\...\.......\....\....\....\FakeCashPeopleSubmitOutStoreTest.java
.......\...\.......\....\....\fake
.......\...\.......\....\cash
.......\...\.......\cibs
.......\...\bocsoft
.......\com
testsrc
.......\...\.......\....\....\....\BfwTest.java
.......\...\.......\....\....\....\DummyContext.java
.......\...\.......\....\....\....\FakeCashPeopleSubmitOutStoreTest.java
.......\...\.......\....\....\fake
.......\...\.......\....\cash
.......\...\.......\cibs
.......\...\bocsoft
.......\com
testsrc