Junit测试基本用法
来源:互联网 发布:c语言的缺陷与陷阱pdf 编辑:程序博客网 时间:2024/05/16 08:48
1、一组测试
@RunWith(Parameterized.class)public class ParameterTest { /* * 1.更改默认的测试运行器为RunWith(Parameterized.class) * 2.声明变量来存放预期值 和结果值 * 3.声明一个返回值 为Collection的公共静态方法,并使用@Parameters进行修饰 * 4.为测试类声明一个带有参数的公共构造函数,并在其中为之声明变量赋值 */ int expected =0; int input1 = 0; int input2 = 0; @Parameters public static Collection<Object[]> t() { return Arrays.asList(new Object[][]{ {3,1,2}, {4,2,2} }) ; } public ParameterTest(int expected,int input1,int input2) { this.expected = expected; this.input1 = input1; this.input2 = input2; } @Test public void testAdd() { assertEquals(expected, new Calculate().add(input1, input2)); }}
2、多个类一起测试
@RunWith(Suite.class)@Suite.SuiteClasses({TaskTest1.class,TaskTest2.class,TaskTest3.class})public class SuiteTest { /* * 1.测试套件就是组织测试类一起运行的 * * 写一个作为测试套件的入口类,这个类里不包含其他的方法 * 更改测试运行器Suite.class * 将要测试的类作为数组传入到Suite.SuiteClasses({}) */}
0 0
- Junit测试基本用法
- JUnit 单元测试基本用法
- JUnit基本用法
- junit基本用法
- 开发工具之MyEclipse用法基本总结(断点测试,快捷键,Junit测试)
- 开发工具之MyEclipse用法基本总结(断点测试,快捷键,Junit测试)
- 开发工具之MyEclipse用法基本总结(断点测试,快捷键,Junit测试)
- Junit测试代码基本骨架
- JUnit 4的基本用法
- android Junit测试基本讲解1
- Android基础学习:Junit测试基本配置
- Junit的基本用法 更多选项
- JUnit学习笔记(一):基本用法
- java junit 软件测试断言用法举例
- Eclipse调试,以及JUnit测试工具用法
- junit 测试中各种断言用法
- junit 测试中各种断言用法
- junit测试assert各种断言用法
- MONGODB 检查点和JOURNAL说明
- java相关开发包官网下载地址
- Git的使用
- jQuery对象复制
- 118 系统视频播放
- Junit测试基本用法
- Ext学习笔记——grid表格渲染自定义样式
- 滚动条插件nanoScroll的使用示例
- CentOS6.4 中httpd Apache安装方法
- 浙江大学MOOC学习——图的建立
- 山东理工ACM:1154
- 实现Dialog自动关闭
- javaSE(03)
- 山东理工ACM:1174(用函数方法)