1 package com.mockobjects.examples.calcserver; 2 3 import com.mockobjects.util.TestCaseMo; 4 5 8 9 public class TestCalculator extends TestCaseMo { 10 private static final Class THIS = TestCalculator.class; 11 12 Calculator myCalculator = new Calculator(); 13 14 15 public TestCalculator(String name) { 16 super(name); 17 } 18 19 20 public static void main(String [] args) { 21 start(new String []{ THIS.getName()}); 22 } 23 24 25 public void testAdd() throws CalculatorException { 26 assertEquals("add", 9, myCalculator.calculate(5, 4, "/add")); 27 } 28 29 30 public void testBadOperation() { 31 try { 32 myCalculator.calculate(5, 4, "Bad operation"); 33 fail("Should have thrown an exception"); 34 } catch (CalculatorException expected) { 35 } 36 } 37 38 39 public void testSubtract() throws CalculatorException { 40 assertEquals("subtract", 1, myCalculator.calculate(5, 4, "/subtract")); 41 } 42 } | Popular Tags |