How to JUnit test a Method with a Scanner?
问题 I have a class which reads a file and takes in a user input with a scanner and if the scanner equals a part of a line in that file, it will display a string from the same line. How would I go and create a Junit test method for this? Here is some of my code that I want a test method for: Scanner Input = new Scanner(System.in); String name = Input.nextLine(); BufferedReader br; try{ br = new BufferedReader(new FileReader(new File(filename))); String nextLine; while ((nextLine = br.readLine()) !