@Test public void testDivide() { a = 8; b = 2; int result = calculator.divide(a, b); Assert.assertEquals(a / b, result); a = 8; b = -2; result = calculator.divide(a, b); Assert.assertEquals(a / b, result); }
@Test public void testDivideByZero() { a = 20; b = 0; Integer result = calculator.divide(a, b); Assert.assertNull(result); }
@Test(expected = Exception.class) public void divisionWithException() { // divide by zero calculator.divide(42, 0); }