calculatoracceptancetest.java
来自「不管是测试驱动开发或者是其它的开发模式」· Java 代码 · 共 36 行
JAVA
36 行
/* Copyright (c) 2000-2004 jMock.org
*/
package test.jmock.calculator.acceptance;
import junit.framework.TestCase;
import org.jmock.examples.calculator.Calculator;
public class CalculatorAcceptanceTest extends TestCase
{
private Calculator calculator;
public void setUp() {
calculator = new Calculator();
}
public void testLiteral() throws Exception {
assertEquals("should be 9", 9, calculator.calculate("9"), 0);
}
public void testSimpleCalculation() throws Exception {
assertEquals("should be 7", 7, calculator.calculate("1 + 2 * 3"), 0);
}
public void testCalculationWithVariables() throws Exception {
calculator.setVariable("x", "1 + 2");
calculator.setVariable("y", "x * 3");
assertEquals("should be 9", 9, calculator.calculate("y"), 0);
}
public void testCalculationWithParentheses() throws Exception {
assertEquals("should be 9", 9, calculator.calculate("(1+2)*3"), 0);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?