re: When do you write your tests? VIEW POST

re: It's the first time I heard of "red-green-refactor" catchphrase, but isn't it supposed to be "red-refactor-green"? 😅

I believe it's really red-green-refactor, as Wikipedia and several other articles confirm:

Each test case fails initially: This ensures that the test really works and can catch an error. Once this is shown, the underlying functionality can be implemented. This has led to the "test-driven development mantra", which is "red/green/refactor", where red means fail and green means pass. Test-driven development constantly repeats the steps of adding test cases that fail, passing them, and refactoring.

The principle is that, if we're in the red, it's not possible to refactor confidently, because you don't know whether the current code to be refactored is correct, or even exists at all!

code of conduct - report abuse