volume_mute

Why the Initial Test Must Fail

publish date2026/06/18 05:45:5.504294 UTC

volume_mute

In TDD, after writing a test for new functionality, the developer runs the test and expects it to fail. Why is this initial failure important?

Correct Answer

It confirms the test is actually checking the intended functionality and that the functionality does not already exist

Explanation

The initial failure of the test is essential confirmation that the test is correctly checking the intended functionality and that this functionality has not already been implemented elsewhere. If the test passes immediately, it may mean the test is wrong, or the feature already exists. The fail-first rule ensures the test has meaningful content.

Reference

Software Engineering, Ian Sommerville, 10th edition


Quizzes you can take where this question appears