您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源單元測(cè)試工具 > junit
JUnit4概述(二)
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/12/10 9:29:08 ] 推薦標(biāo)簽:

package andycpp;

import static org.junit.Assert.*;

import org.junit.Before;

import org.junit.Ignore;

import org.junit.Test;

public class CalculatorTest ...{

    private static Calculator calculator = new Calculator();

      @Before

    public void setUp() throws Exception ...{

        calculator.clear();

    }

    @Test

    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

    public void testDivide() ...{

        calculator.add(8);

        calculator.divide(2);

        assertEquals(4, calculator.getResult());

    }

}

相關(guān)鏈接:
上一頁(yè)1234下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd