'Making automated tests for a basic tic tac toe game

As the title says, I am making automated test cases for a tic tac toe game, however I use the scanner nextInt method within the method I'm trying to test, i just dont understand how to make my test case automatically fill the input rather than the program asking the user. Here are the two methods:

Main class method:

public static void playGame(String playerOne, String playerTwo, char[][] gameBoard, int playerNum, Scanner input) {
        int moveSelected = 0;
        while (moveSelected >= 10 || moveSelected <= 0) {
            moveSelected = 0;
            try {
                if (playerNum == 1) {
                    System.out.println(playerOne + " please input your spot selection(1-9)");
                } else {
                    System.out.println(playerTwo + " please input your spot selection(1-9)");
                }
                moveSelected = input.nextInt();
            }
            catch(InputMismatchException e){
                System.err.println("Wrong input! Integer Values Only.");
                input.next();
            }
        }

        playerMove(moveSelected, playerNum, gameBoard);
        displayBoard(gameBoard);
    }

Test Method:

public void testplayGame(){
        Scanner input = new Scanner(System.in);
        char[][] gameBoard = {{' ', '|', ' ', '|', ' '},
                {'-', '+', '-', '+', '-'},
                {' ', '|', ' ', '|', ' '},
                {'-', '+', '-', '+', '-'},
                {' ', '|', ' ', '|', ' '}};
        for(int i =1; i<10;i++) {
            assertEquals(fstTest.playGame("p1","p2",gameBoard,1,input));
        }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source