March 2018
Intermediate to advanced
324 pages
8h 30m
English
Software concepts are often easiest to explain through code, and this one is no exception. We have seen and worked with the Tic-Tac-Toe application (see Chapter 3, Red-Green-Refactor – From Failure Through Success until Perfection). The following code performs position validation:
public class TicTacToe {
public void validatePosition(int x, int y) {
if (x < 1 || x > 3) {
throw new RuntimeException("X is outside board");
}
if (y < 1 || y > 3) {
throw new RuntimeException("Y is outside board");
}
}
}
The specification that corresponds with this code is as follows:
public class TicTacToeSpec { @Rule
public ExpectedException exception =
ExpectedException.none();
private TicTacToe ticTacToe; @Before public final void before() ...Read now
Unlock full access