Since we are using TDD, we can probably think of our tests as our design. We start by creating a test for a specific feature/requirement, and then we write the code needed to satisfy the test. In essence, we are designing our application by writing tests. For example, if we want to accept only usernames that contain only letters and that are three or more characters long, then we will write a test for that followed by code to satisfy the test.
As mentioned in the previous chapter, the registration process involves the following steps:
Collect name, email, password, security question and answer.
Ensure username is unique.
Ensure username is valid:
It is 4 characters or more.
It starts with a letter.
It contains only letters, numbers, and underscore.
Ensure email is unique and valid.
Create the user account and log the user in.