From 2a7211e720a01b4ecb0c0c02c8da1819e801f5ab Mon Sep 17 00:00:00 2001 From: elliottchoi Date: Tue, 26 Jan 2016 00:18:00 -0500 Subject: [PATCH] Create J unit Testing --- J unit Testing | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 J unit Testing diff --git a/J unit Testing b/J unit Testing new file mode 100644 index 0000000..f32f9cf --- /dev/null +++ b/J unit Testing @@ -0,0 +1,38 @@ +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +//assertEquals(expected, actual, 0.001) delta is for precision +public class BankAccountTest { + BankAccount testAccount; + + @Before + public void setUp() throws Exception { + testAccount = new BankAccount("Test case", 123.45); + } + + @Test + public void testWithdraw() { + testAccount.withdraw(23.64); + assertEquals("Test case $99.81", testAccount.toString()); + } + + @Test + public void testAddInterest() { + BankAccount.setInterestRate(5.0); + testAccount.addInterest(); + assertEquals("Test Case $123.96", testAccount.toString()); + } + + @Test + public void testIsBalanceOver() { + // First Parameter is the expected result, the second result is the + // actual result + assertTrue(testAccount.isBalanceOver(123.43)); + assertTrue(testAccount.isBalanceOver(123.44)); + assertFalse(testAccount.isBalanceOver(123.45)); + assertFalse(testAccount.isBalanceOver(123.46)); + } + +}