zoukankan      html  css  js  c++  java
  • GITHUB随笔 15-5月 junit

    junit 是用来做单元测试的一个工具  测试是一个持续的过程。也就是说测试贯穿与开发的整个过程中,单元测试尤其适合于迭代增量式的开发过程。

    @ignore:   该元数据标记的测试方法在测试中会被忽略。当测试的方法还没有实现,或者测试的方法已经过时,或者在某种条件下才能测试该方法(比如需要一个数据库联接,而在本地测试的时候,数据库并没有连接),那么使用该标签来标示这个方法。同时,你可以为该标签传递一个String的参数,来表明为什么会忽略这个测试方法。

    import org.junit.After;
    import org.junit.Before;
    import org.junit.Ignore;
    import org.junit.Test;
    //import org.junit.internal.runners.calculator;
    import org.junit.runner.RunWith;


    //@RunWith(calculator.class)
    public class calculatorTest {

    private static calculator calculator=new calculator();


    @Before
    public void setUp() throws Exception {
    calculator.clear();
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test(timeout=1000)
    public void testAdd() {
    calculator.add(2);
    calculator.add(3);
    assertEquals(5, calculator.getResult());
    }

    @Test
    public void testSubstract() {
    calculator.add(10);
    calculator.substract(2);
    assertEquals(8,calculator.getResult());
    }

    @Ignore("Multiply() Not yet implemented")
    @Test
    public void testMultiply() {

    }

    @Test(expected =ArithmeticException.class)
    public void testDivide() {
    calculator.add(8);
    calculator.divide(0);
    assertEquals(4,calculator.getResult());
    }

    https://github.com/y654063871/calculator/commit/0d4bf37dec36ab2a42453addd1957dbeccfd5269

  • 相关阅读:
    问题解决-Plugin with id 'com.github.dcendents.android-maven' not found
    hadoop 04 一 HA高可用配置
    hadoop 03 一 Hadoop机架感知配置
    Windows平台安装配置Hadoop
    hadoop 02一 hadoop配置
    hadoop 01一 hadoop安装配置
    Centos7下载和安装教程
    mysql 命令行导出数据
    RabbitMQ 集群部署(linux-centos6.5)
    Spring 集成RabbitMq
  • 原文地址:https://www.cnblogs.com/y654063871/p/4486251.html
Copyright © 2011-2022 走看看