Question: Junit testing case Here are my methods I want to test. Scanner scan = new Scanner(System.in).useDelimiter(); public String prompt_FirstName() { System.out.println(First Name:); String firstName =

Junit testing case

Here are my methods I want to test.

Scanner scan = new Scanner(System.in).useDelimiter("");
public String prompt_FirstName() {    System.out.println("First Name:");    String firstName = scan.next();    return firstName;}
 

Here's what i have so far

@Testpublic void testPrompt_first(){    Menu inputOutput= new Menu();    String input = "Jane";    InputStream in = new ByteArrayInputStream(input.getBytes());    System.setIn(in);    String s = inputOutput.prompt_FirstName();    assertEquals("Jane", s);}

Step by Step Solution

3.60 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Based on the provided code snippet it seems that you are trying to write a JUnit test case for the p... View full answer

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 Programming Questions!