TDD is a three-part cycle:
Write a test that fails.
Get the test to pass.
Clean up any code added or changed in the prior two steps.
Your first step is to write a test that defines the behavior you want to build into the system. In general, you seek to write the test that represents the smallest possible—but useful—increment to the code that already exists.
For our exercise, we’re rebuilding the Profile class. We think about the simplest cases that can occur and decide to write a test that demonstrates what happens when the profile is empty (when no answers have been added to it).
(If you have a Profile class, start this exercise by deleting it and any tests for it. Or start fresh in a new package or project.)
We’ll write our ...