O'Reilly logo

Test-Driven Java Development by Alex Garcia, Viktor Farcic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Developing Tic-Tac-Toe

Are you ready to code? Let's start with the first requirement.

Requirement 1

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

Note

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 Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required