Junit 套件
来源:互联网 发布:sql 列别名 编辑:程序博客网 时间:2024/06/09 18:53
Parameterized 参数化运行器:
/* * ======================================================================== * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ======================================================================== */import static org.junit.Assert.assertEquals;import java.util.Arrays;import java.util.Collection;import org.junit.Test;import org.junit.runner.RunWith;import org.junit.runners.Parameterized;import org.junit.runners.Parameterized.Parameters;/** * A sample parameterized test-case. * * @version $Id: ParameterizedTest.java 551 2010-03-06 11:37:34Z paranoid12 $ */@RunWith(value=Parameterized.class)public class ParameterizedTest { private double expected; private double valueOne; private double valueTwo; @Parameters public static Collection<Integer[]> getTestParameters() { return Arrays.asList(new Integer[][] { {2, 1, 1}, //expected, valueOne, valueTwo {3, 2, 2}, //expected, valueOne, valueTwo {4, 3, 1}, //expected, valueOne, valueTwo }); } public ParameterizedTest(double expected, double valueOne, double valueTwo) { this.expected = expected; this.valueOne = valueOne; this.valueTwo = valueTwo; } @Test public void sum() { Calculator calc = new Calculator(); assertEquals(expected, calc.add(valueOne, valueTwo), 0); } }
Suite套件:
suite对象其实是一个Runner,可以执行测试类中所有@Test注释的方法
public class TestCaseA {@Testpublic void testA1() {assertEquals("Dummy test-case", 1+1, 2);}}
将测试类组合成一个Suite(测试集)
@RunWith(value = Suite.class)@SuiteClasses(value = { TestCaseA.class })public class TestSuiteA {}
然后把测试集又组合成一个主测试集
@RunWith(value = Suite.class)@SuiteClasses(value = { TestSuiteA.class, TestSuiteB.class })public class MasterTestSuite {}
- Junit 套件
- junit的测试套件
- JUnit测试套件
- junit测试套件
- junit之使用套件
- JUnit创建套件测试
- JUnit教程-- 创建套件测试
- Junit单元测试和套件使用
- 在NetBeans中开发JUnit测试套件
- Android JUnit单元测试周期,异常,测试套件
- Junit学习笔记之-- 测试套件
- Junit使用教程--整合spring测试套件
- Junit测试套件及参数化设置
- Android Junit单元测试-声明套件类
- JUnit单元测试(四)--JUnit运行测试套件
- Junit 4 Tutorials(Junit 4 教程) 五、测试套件
- JUnit 入門- 測試套件(TestSuite)
- JUnit中的测试套件和参数化测试
- Flex中采用Flex-config.xml进行命令行的编译
- 关于 Android SDK r20.0.1 更新后,Hierarchical Parent 必须填写的解决办法
- mysql 主从 配置 步骤 方法
- 关于mongoDb(安装和配置)二
- 数据结构学习之链队列c++实现
- Junit 套件
- 遍历HashMap
- dbms_repair包修复坏块
- gluPerspective和gluLookAt的关系
- 关于mfc中的屏蔽右键菜单
- 倾诉孤独真是伤感日志:我对你的爱净重21克
- DateUtils
- Failed to allocate nodeid for API at 192.168.55.9. Returned eror: 'No free node id found for mysqld
- RFID数据传输常用编码格式