I'm writing a unit test for the following method of my tic-tac-toe program. I would like to follow a TDD approach but the method requires user input.
public int[] playerMove(){
Scanner reader = new Scanner(System.in);
int[] move = new int[2];
move[0] = reader.nextInt()-1;
move[1] = reader.nextInt()-1;
return move;
}
My problem is that I can't input test numbers for move[0]
and move[1]
since it requires user input which is supplied via System.in
. How would simulate this during my test?