Test – O plays right after X

Now, we should make sure that players are changing. After X is finished, it should be O's turn, then again X, and so on:

@Testpublic void givenLastTurnWasXWhenNextPlayerThenO() {
  ticTacToe.play(1, 1);
  assertEquals('O', ticTacToe.nextPlayer());
}
If the last turn was played by X, then the next turn should be played by O.

Get Test-Driven Java Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.