Test guide – we drive the design
In Chapter 5, Writing Our First Test, we wrote our first test. To do that, we ran through a number of design decisions. Let’s review that initial test code and list all the design decisions we had to make, as follows:
@Test public void oneIncorrectLetter() { var word = new Word("A"); var score = word.guess("Z"); assertThat( score.letter(0) ).isEqualTo(Letter.INCORRECT); }
We decided on the following:
- What to test
- What to call the test
- What to call the method under test
- Which class to put that method on
- The signature of that method
- The constructor signature of the class
- Which other objects should collaborate
- The method signatures involved in that collaboration
- What form the output of this method will take
- How to access that output and assert that it worked
These are all design decisions that...