Red > Green > Clean

The goal of TDD is Clean Code That Works

...which is 2 problems to solve [clean code, that works] and many devs will try to solve both problems at once...which is a lot to think about 🤯

With TDD you first focus on working code THEN clean code

Let's look at the 5 steps which we previously discussed and break them doen into 3 distinct phases (Red | Green | Clean) and see how they can point us in the direction of our goal.

Note that there has been a subtle change to one of the error messages since I recorded this. Around the 2:15 mark you will see me get an error which says:

'Attempt to read property "amount" on null'

But it is quite likely that you will see this instead:

Failed asserting that null matches expected 10

They both refer to the same thing so don't worry if your message is different then mine. I now get the latter error using an updated version of PHPUnit.

Lesson branch: https://github.com/GaryClarke/testing-php-tdd/tree/red-green-clean

Complete and Continue  
Discussion

10 comments