import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; public class CalculatorTest { private Calculator calculator; @Before public void setUp() { calculator = new Calculator(); } @Test public void testAddition() { int result = calculator.add(2, 3); assertEquals(5, result); } @Test(expected = ArithmeticException.class) public void testDivisionByZero() { calculator.divide(10, 0); } }


上一篇:
下一篇:
切换中文