public void testIllegalCalculate() { try { interestCalculator.calculate(-10000, 2); fail("No exception on illegal argument"); } catch (IllegalArgumentException e) { } }
// main method public static void main(String[] args) { InterestCalculator application = new InterestCalculator(); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } // end method main
@Test(expectedExceptions = IllegalArgumentException.class) public void illegalCalculate() { interestCalculator.calculate(-10000, 2); }
@Test public void calculate() { double interest = interestCalculator.calculate(10000, 2); assertEquals(interest, 1000.0); }
@BeforeMethod public void init() { interestCalculator = new SimpleInterestCalculator(); interestCalculator.setRate(0.05); }
protected void setUp() throws Exception { interestCalculator = new SimpleInterestCalculator(); interestCalculator.setRate(0.05); }