Question: 3. You are doing unit test using JUunit for the methods of the Account class code that is given below. Write the appropriate assertion
3. You are doing unit test using JUunit for the methods of the Account class code that is given below. Write the appropriate assertion statements so that the tests pass in the three different versions of the test program given below. [3] public class Account private String name; private double balance; private boolean overDraft Protection; public Account (String name, double balance, t } public void deposit (double } A if (depositAmount > 0.0) } boolean overDraft Protection) this.name name; if (balance > 0.0) this.balance balance; { } balance public double getBalance() return balance; balance + depositAmount; public void setover Draft Protection( depositAmount) boolean overDraft Protection) this.overDraft Protection - overDraft Protection; public boolean getover Draft Protection () return overDraft Protection; public void setName (String name) this.name name; public String getName()) return name; // end class Account import static org.junit.Assert.assertEquals; import org.junit. Test: public class TestAccount ( @Test public void accountEvaluator () ( String name "John Doe"; double bal - 750.00; // balance boolean odp- true; // Overdraft Protection Account ac new Account (name, bal, odp); double balance ac.getBalance(); // TO DO- assertion code, test to pass Code Listing 2: Test for Account Balance import static org.junit.Assert.assertEquals; import org.junit. Test: public class TestAccount ( @Test public void accountEvaluator() { String name "John Doe"; double bal - 750.00: boolean odp- true; // Overdraft Protection Account ac new Account (name, bal, odp): ac.deposit (500.0); double balance - ac.getBalance (); // TO DO assertion code, test to pass Code Listing 3: Test for Deposit import static org.junit.Assert.assertFalse; import org. junit. Test; public class TestAccount ( @Test public void account Evaluator () { String name= "John Doe"; double bal - 750.0; // balance. boolean odp= true; // Overdraft Protection Account ac new Account (name, bal, odp); ac.setOverDraft Protection (false); boolean cond ac.getOverDraft Protection (); // TO DO assertion code, test to pass
Step by Step Solution
3.46 Rating (153 Votes )
There are 3 Steps involved in it
It looks like youre working on creating unit tests for the Account class using JUnit and you need to ... View full answer
Get step-by-step solutions from verified subject matter experts
