I want to test method setDay() using arguments [-1,0,24,2,32].
I know that Scanner reader can be
String test="-1 0 24 2 32";
 Scanner reader=new Scanner(test);
The main problem is infinite loop and void method. How can we test this kind of code? Here is example code:
public NameOfTheDay(){
   int day=1;     
}
{...}
public void setDay(Scanner reader) {
    while (true) {
        System.out.print("Day: ");
        String input = reader.nextLine();
        if (input.matches("\\d{2}")) {
            int day = Integer.parseInt(input);
            if (day > 0 && day < 32) {
                this.day = day;
                return;
            }
        }
        System.out.println("Wrong day. Try again.");
    }
}
Thanks for the answer.
 
     
    