March 2018
Intermediate to advanced
324 pages
8h 30m
English
Whenever we play a turn, it should be saved to the DB. The specification can be the following:
@Test
public void whenPlayThenSaveMoveIsInvoked() {
TicTacToeBean move = new TicTacToeBean(1, 1, 3, 'X');
ticTacToe.play(move.getX(), move.getY());
verify(collection).saveMove(move);
}
By now, you should be familiar with Mockito, but let us go through the code as a refresher:
TicTacToeBean move = new TicTacToeBean(1, 1, 3, 'X');
ticTacToe.play(move.getX(), move.getY());
verify(collection, times(1)).saveMove(move); ...
Read now
Unlock full access