Three Rules of TDD

Profile picture for user arilio666

The Three Rules To Be Followed While Implementing TDD/ Test Driven Development Are:-

  1. An individual should not write production code unless the main aim is to make a failing unit test pass.
  2. An individual should not try to write a unit test any more than sufficient to fail, and compilation failures are failures.
  3. An individual should not try to write any more production code than is sufficient to pass the one failing the unit test.

Let us uncover the rules in detail:

  • We must follow writing a unit test for the functionality we intend to write. But according to Rule #2, we cant write much of the unit test.
  • As soon as the unit test fails to compile an assertion, we must stop and start writing production code. But according to Rule #3, we can write production code only if the test collects or pass.
  • When it comes to thinking about this, we cannot simply write very much code without compiling and executing something.
  • We keep the system executing at all times, whether it is writing tests, writing production code, etc.