Practice question · Multiple choice
Test-driven development requires the new test to FAIL before any code is written. Why is that step not a waste of time?
Hints
- Imagine a test with a typo in its assertion that passes on an empty codebase.
- What has a green test told you if it was green already?
Show the answer
A. Because a test that passes before the feature exists is testing nothing
Why
The red step validates the test itself. Skipping it is how suites fill with tests that would pass no matter what the code did.
Practise Testing Larger Behaviours
The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Testing Larger Behaviours
- Sort each claim by whether a coverage report can actually support it.
- Every unit test in a project passes. Select every kind of defect that could still be present.
- A test suite runs in four hours and developers stop running it before pushing. What has the suite become?
- A test suite can execute every line of a function and still miss the input that breaks it.