Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

Here is an Example Format of The Junit Tests

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

Explain the phases in the Balanced Mediation Model

Answered: 1 week ago

Question

Understand the different approaches to job design. page 167

Answered: 1 week ago