JUnit testing with simulated user input
问题 I am trying to create some JUnit tests for a method that requires user input. The method under test looks somewhat like the following method: public static int testUserInput() { Scanner keyboard = new Scanner(System.in); System.out.println(\"Give a number between 1 and 10\"); int input = keyboard.nextInt(); while (input < 1 || input > 10) { System.out.println(\"Wrong number, try again.\"); input = keyboard.nextInt(); } return input; } Is there a possible way to automatically pass the program