Requirement 1 – placing pieces

We should start by defining the boundaries and what constitutes an invalid placement of a piece.

A piece can be placed on any empty space of a 3×3 board.

We can split this requirement into three tests:

  • When a piece is placed anywhere outside the x-axis, then RuntimeException is thrown
  • When a piece is placed anywhere outside the y-axis, then RuntimeException is thrown
  • When a piece is placed on an occupied space, then RuntimeException is thrown

As you can see, the tests related to this first requirement are all about validations of the input argument. There is nothing in the requirements that says what should be done with those pieces.

Before we proceed with the first test, a brief explanation of how to test ...

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.