TDD pillars
TDD is a set of practices that specify how and when a unit test should be written. You can write unit tests without TDD, but TDD has to have a type of test associated with it. Sometimes, you can hear TDD and unit tests used as if they mean the same thing, but they are not.
While the ecosystem around TDD is sophisticated as it touches a lot of software engineering aspects, TDD as a standalone concept is easy to explain and understand. We can summarize TDD as these two pillars:
- Test first
- Red, Green, Refactor (RGR)
Let’s discuss these pillars.
Test first
The idea here is to start with the tests before starting with the production code. It really means testing code that doesn’t exist yet!
Testing first changes the way we write code, as now you are redirected to think about your classes' structure and public methods before the implementation. This encourages the developer to reflect on the design from the client’s perspective...