Test-driven development was developed or discovered by Kent Beck in 1993. In this approach, we write test cases before writing any piece of code. The mantra of TDD is "red, green, and refactor" as shown in the picture below.
This approach looks easy, but it is actually quite hard to follow. It requires some practice to change regular coding habits.In the case of TDD, a programmer writes test cases first and then writes code to pass the test cases, and, finally, refactors the working code after passing all test cases.