Question: Write two Junit tests for one method: Write a Passing & Failing Junit Test for the print() method below. Here is an Example Format of

Write two Junit tests for one method:

Write a Passing & Failing Junit Test for the print() method below.

Write two Junit tests for one method: Write a Passing & Failing

Here is an Example Format of The Junit Tests

Junit Test for the print() method below. Here is an Example Format

void testIsPrintValidPASS() {

//test code

}

void testIsPrintValidFAIL() {

//test code

}

@Override public void print() { String fileContent = 'check# "+this. number+" "+ date: " +this.date+" "+ "payee: "+this.payee+" "+"$ "+this.amount+" "+ "accountID:"+this accountID+" bankID:"+this.bankID+" " + ------"; FileWriter fileWriter = null; try { fileWriter = new FileWriter("CheckFile. txt"); '} catch (IOException exception) { System.out.println("An error occurred.") exception.printStackTrace(); PrintWriter printwriter = new PrintWriter(fileWriter); printWriter.print(fileContent); printwriter.close(); public boolean isPrintvalid() { boolean retValue = true; if(????) { retValue = false; return retValue; // Validations public boolean isAccountIdValid() { boolean retValue = true; if(accountID == null) { retValue = false; return retValue; @Test void testIsAccountIdValidPASS() { Check check = new Check check.setAccountID("myAccount8") boolean expected Result = true; boolean actualResult = check.isAccountIdValid(); assertEquals(expectedResult, actualResult); @Test void testIsAccountIdValidFAILO { Check check = new Check check.setAccountID(nullo boolean expected Result = false; boolean actualResult = check.isAccountIdValid(); assertEquals(expectedResult, actualResult); @Override public void print() { String fileContent = 'check# "+this. number+" "+ date: " +this.date+" "+ "payee: "+this.payee+" "+"$ "+this.amount+" "+ "accountID:"+this accountID+" bankID:"+this.bankID+" " + ------"; FileWriter fileWriter = null; try { fileWriter = new FileWriter("CheckFile. txt"); '} catch (IOException exception) { System.out.println("An error occurred.") exception.printStackTrace(); PrintWriter printwriter = new PrintWriter(fileWriter); printWriter.print(fileContent); printwriter.close(); public boolean isPrintvalid() { boolean retValue = true; if(????) { retValue = false; return retValue; // Validations public boolean isAccountIdValid() { boolean retValue = true; if(accountID == null) { retValue = false; return retValue; @Test void testIsAccountIdValidPASS() { Check check = new Check check.setAccountID("myAccount8") boolean expected Result = true; boolean actualResult = check.isAccountIdValid(); assertEquals(expectedResult, actualResult); @Test void testIsAccountIdValidFAILO { Check check = new Check check.setAccountID(nullo boolean expected Result = false; boolean actualResult = check.isAccountIdValid(); assertEquals(expectedResult, actualResult)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!