What is red / green testing?

I believe that I already know the answer, but I'm not 100% sure, so just a question: what does Red / Green Testing mean?

I understand this as "First write your tests so that they all fail (= all red), then write your code and see how each test turns green, and when everything is green, you're fine."

I heard this in Scott MVC Talk at Mix , so I don’t know if this is the "official" term, or if they just made it up. (Editing: Scott actually also explains this, starting at 55:00, and he made a good point about why he has one)

+4
source share
3 answers

This applies to TDD or Test Driven Development, but this applies to each test. First write a test, then write a code to pass the test. It would be wrong to write ALL tests in the first place. TDD is an incremental development approach.

The basic idea is that the code is not written before the test (RED) passes. When you have a failed test, you write code to pass the test (GREEN). Now you are ready to write the next test, i.e. No new tests until everyone turns green. Or refactoring, as @Brian points out.

+11
source

"Red-Green-Refactor" is the TDD mantra.

http://en.wikipedia.org/wiki/Test-driven_development

When I'm on the sugar wave after worshiping the afternoon in a candy dish in the office, I sometimes scream these words when I code. It's easier to write tests when you reward yourself after writing a failed test case by shouting "Red!". and eat a piece of chocolate. :)

+8
source

When you start the TDD GUI, the display stays red until all tests pass, then it switches to green.

This is a brief description of a rough test development plan.

  • Write some skeletal code that compiles, has enough API to validate.

  • Write tests that - initially - will be mostly failures. Red.

  • Complete the code. Tests pass. Green.

At this point, you have something that works. However, you do not have very high quality. Therefore, you will need to reorganize to improve overall quality.

+3
source

Source: https://habr.com/ru/post/898757/


All Articles