In this episode, you will learn the basics of the TDD process while walking through the Red-Green-Refactor steps. Red-Green-Refactor describes the steps that you follow when practicing the TDD process.
The first step is the red step. Here you start by writing a failing (red) test. This is for any new feature, behavior change, or bug fix that doesn’t already have a test for what you will be doing. You only write the tests and the bare minimum code to make it compile. Make sure you run the test and see it fail.
The second step is the green step. It involves writing the minimum code to make the test pass. You’re not worried about making it pretty or adding any additional functionality at this step.
The last step is refactor. This is when you prettify your code and make any needed changes to make sure it is clean. You know that your changes are safe and correct as long as your tests stay green.
Lets put the red green refactor steps into practice!