TDD – What Happens Before the First Unit Test

designtdd

I mostly understand the theory of TDD, but I can't figure out how to get started. I sit down to write a unit test for a personal project and realize . . . I have no idea what I am testing. What objects, what functionality, etc.

E.g., let's say I want to write an app to help our family manage chore assignments. Here are some questions in my mind: How do I go from this idea to my first test? How much should be decided before I start, and how much do I figure out after I start writing tests? When do I make decisions like whether to store data in a text file or a database? Should I have user acceptance tests before I get started? Should I have the UI designed? Should I have a spec? (I do realize at least some of these example questions are probably in a "gray area").

In addition to the title question about getting to the first unit test, could you also give an example of what the first unit test for a project like the sample project might look like?

Best Answer

I like to start with a list of Features, and for each Feature write the user stories, then for each story write test descriptions.

Think about the design for a bit, then pick a test description and start coding: red-green-refactor.

Repeat until all tests pass.

Yes, acceptance tests should be considered as part of this, attached to the appropriate story.