March 2018
Intermediate to advanced
324 pages
8h 30m
English
What happens if a move could not be saved? Our helper method saveMove returns true or false depending on the MongoDB operation outcome. We might want to throw an exception when it returns false.
First things first: we should change the implementation of the before method and make sure that, by default, saveMove returns true:
@Before
public final void before() throws UnknownHostException {
collection = mock(TicTacToeCollection.class);
doReturn(true).when(collection).saveMove(any(TicTacToeBean.class));
ticTacToe = new TicTacToe(collection);
}
Now that we have stubbed the mocked collection with what we think is the default behavior (return true when saveMove is invoked), we can proceed and write the specification: ...
Read now
Unlock full access