Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

The “Red, Green, Refactor” Cycle

Sumit Rawal answered on August 25, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


The “Red, Green, Refactor” Cycle

0

Write a failing test. You’re writing your tests before your app code, so you know this test is going to fail. You haven’t implemented the feature yet! This is considered the “red” state (some tests failing).

Make the test pass. Here you write your app code, so you actually implement whatever functionality the test is looking at. Once you have your test passing, you’re now in the “green” state (all tests passing).

Refactor. Now that your test is passing, go make your code better. As the famous quote from Kent Beck goes: “Make it work. Make it right. Make it better. In that order.” Note that we don’t refactor until we’re in the “green” state. By having all our tests passing, we can refactor with confidence because if we break something, tests will start failing again, letting us know our refactor isn’t working perfectly yet.

Repeat. Go write another test now! Continue to loop through steps 1–3 as you write more tests and implement more functionality in your app. 

Popularity 1/10 Helpfulness 1/10 Language whatever
Source: Grepper
Tags: cycle whatever
Link to this answer
Share Copy Link
Contributed on Aug 25 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.