Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is red/green testing?

I believe I already know the answer, but I am not 100% sure, so just a quick question: What does Red/Green Testing actually mean?

I understand it as "Write your tests first, so that they all fail (= all red), then write your code and watch how each test turns green, and when all are green, you're fine".

I heard this in Scott's MVC Talk at Mix, so I do not know if this is an "official" term or if he just made it up. (Edit: Scott actually also explains it starting at 55:00 Minutes, and he made a good remark why he beleives in it)

like image 317
Michael Stum Avatar asked Nov 10 '08 01:11

Michael Stum


People also ask

What is red testing?

A term that fills a lexical void, for the first “live” and independent performance of an act or process for which a person has trained for a long period of time.

What is red Green refactoring?

Red Green Refactor is the Agile engineering pattern which underpins Test Driven Development. Characterized by a “test-first” approach to design and implementation, it utilizes very short development cycles to minimize leap-of-faith assumptions.

What are the 3 stages of TDD?

Red, Green and Refactor is the three phase of Test Driven Development and this the sequence that get followed while writing code. When followed, this order of steps helps ensure that you have tests for the code you are writing and you are writing only the code that you have to test for.

Which of the following describes the red phase of the red Green Refactor cycle?

Let's Recap! The Red, Green, Refactor method consists of three phases: Red - write a test that fails. Green - implement the test-supporting functionality to pass the test. Refactor - improve the production code AND the tests to absolute perfection.


1 Answers

It does refer to TDD or Test Driven Development, but it would apply to each test. Write the test first, then write the code to pass the test. It would be wrong to write ALL the tests first. TDD is an incremental development approach.

The basic idea is no code is written before there is failing test (RED). When you have a failing test, then you write the code to pass the test (GREEN). Now you are ready to write the next test -- i.e., no new tests until all are green. Or refactor, as @Brian points out.

like image 51
tvanfosson Avatar answered Nov 15 '22 14:11

tvanfosson