Best Practices for Test Driven Development (TDD) Test-driven development (TDD) is a software development practice that emphasizes writing tests before writing the actual code. It follows a cyclical process of writing a failing test, writing the minimum code to make the test pass, and then refactoring the code.
-If a unit test fails, you should write product code only to pass the unit test.
-You should not write more unit tests.
-You should not write more production codes as compared to what is required for passing a single failing unit test.
-
Arrange: Define the testing environment & values
-
Act: Run the actual code / function that should be tested
-
Assert: Evaluate the produced value / result and compare it to the expected value / result
-Do clean test! -Do test one unit!