O'Reilly logo

Test-Driven Java Development - Second Edition by Viktor Farcic, Alex Garcia

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

Requirement 2 – adding two-player support

Now it's time to work on the specification of which player is about to play his turn.

There should be a way to find out which player should play next.

We can split this requirement into three tests:

  • The first turn should be played by player X
  • If the last turn was played by X, then the next turn should be played by O
  • If the last turn was played by O, then the next turn should be played by X

Until this moment, we haven't used any of the JUnit's asserts. To use them, we need to import the static methods from the org.junit.Assert class:

import static org.junit.Assert.*;

In their essence, methods inside the Assert class are very simple. Most of them start with assert. For example, assertEquals compares ...

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