Requirement 1 – the game's board

We will start with the first requirement.

The board is composed of seven horizontal and six vertical empty positions.

There is no big challenge with this requirement. The board bounds are specified, but there's no described behavior in it; just the consideration of an empty board when the game starts. That means zero discs when the game begins. However, this requirement must be taken into account later on.

This is how the test class looks for this requirement. There's a method to initialize the tested class to use a completely fresh object in each test. There's also the first test to verify that there's no disc when we start the game, meaning that all board positions are empty:

public class Connect4TDDSpec {
  private Connect4TDD tested;
 
@Before public void beforeEachTest() { tested = new Connect4TDD(); }
@Test public void whenTheGameIsStartedTheBoardIsEmpty() { assertThat(tested.getNumberOfDiscs(), is(0)); } }

This is the TDD implementation of the previous specification. Observe the simplicity of the given solution for this first requirement; a simple method returning the result in a single line:

public class Connect4TDD {
public int getNumberOfDiscs() { return 0; } }
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.138.177