Writing our next tests for Wordz
So, what should we write for our next tests? What would be a useful and small-enough step so that we do not fall into the trap of writing beyond what our tests can support? In this section, we will continue building out the Wordz application scoring system using TDD. We will discuss how we choose to move forward at each step.
For the next test, a good choice is to play it safe and move only a small step further. We will add a test for a single correct letter. This will drive out our first piece of genuine application logic:
- Let’s start on red. Write a failing test for a single, correct letter:
@Test
public void oneCorrectLetter() {
var word = new Word("A");
var score = word.guess("A");
assertThat(score.letter(0))
.isEqualTo(Letter.CORRECT);
}
This test is intentionally similar to the one before. The difference is that it tests...