首页>代码>eclipse junit单元测试工具的初次使用>/JUnitTest/src/andycpp/CalculatorTest.java
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(timeout = 1000)
	public void testAdd() {
		//fail("Not yet implemented");
		calculator.add(2);
		calculator.add(3);
		assertEquals(5, calculator.getResult());
	}

	@Test
	public void testSubstract() {
		//fail("Not yet implemented");
		calculator.add(10);
		calculator.substract(2);
		assertEquals(8,calculator.getResult());
	}

	@Ignore("Multiply() Not yet implemented")
	@Test
	public void testMultiply() {
		//fail("Not yet implemented");
		
	}

	@Test(expected =ArithmeticException.class)
	public void testDivide() {
		//fail("Not yet implemented");
		calculator.add(8);
		calculator.divide(2);
		assertEquals(4,calculator.getResult());
	}

}
最近下载更多
阿风啦  LV14 2021年4月4日
doujie  LV5 2020年5月31日
JinghanHe  LV8 2020年3月23日
f1205513291  LV1 2019年12月21日
lironggang  LV38 2019年12月2日
ZpongZ  LV6 2019年10月6日
TY0165  LV20 2018年11月30日
komajojo  LV2 2018年6月21日
1006148200  LV7 2018年6月19日
shanfeng  LV5 2018年4月7日
最近浏览更多
微信网友_5986558820093952  LV4 2024年5月16日
2011502295  LV6 2022年12月27日
阿风啦  LV14 2021年4月4日
lyn520  LV3 2021年1月5日
xiaoyumao  LV2 2020年12月12日
xmjying  LV13 2020年9月16日
渣渣辉壹号 2020年8月25日
暂无贡献等级
cypzuidaima123  LV1 2020年8月14日
qazwsx121212 2020年6月14日
暂无贡献等级
郭QQ159  LV2 2020年6月11日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友