@Test public void test() { try { int result = taxCalculator.calculateTax(grossIncome); Assert.assertEquals(incomeTax, result); if (shouldThrowException) { Assert.fail("This test expected an exception to be thrown, but no exception was thrown."); } } catch (Exception e) { if (!shouldThrowException) { Assert.fail("Should not have thrown an exception: " + e.getMessage()); } } }
double computeIncomeTax(double income) { return calculator.computeIncomeTax(income); }