Second Law of TDD

5 minutes 5 Questions

The Second Law of TDD states that you cannot write more of a unit test than is sufficient to fail. This means you should write just enough of a test to demonstrate failure. It encourages only writing the code necessary to address the failing test, ensuring that the codebase remains concise and uncl…

Test mode:
PMI-ACP - Second Law of TDD Example Questions

Test your knowledge of Second Law of TDD

Question 1

You've written a failing test for a 'SortItems' function. You decide to write just enough code to make the test pass. You then try improving the code to optimize the item sorting. Does this contradict the Second Law of TDD?

Question 2

You have written a failing test for a class method in your eCommerce application. Without making the test pass, you wrote a test for another feature. According to the Second Law of TDD, what should you have done differently?

Question 3

You are working on a program to calculate the area of a shape. You wrote a test for the 'calculateCircleArea' method but it failed because the method is not yet implemented. You now decide to write the 'calculateSquareArea' method. According to the second law of TDD, is this correct?

More Second Law of TDD questions
10 questions (total)