Test-driven development begins by expressing expected behavior as an executable test. The developer observes the test fail, writes the smallest implementation that satisfies it and then improves the design while keeping the test suite passing.
For coding agents, tests written before implementation provide an independent target. Asking the same agent to invent tests after the code risks producing checks that merely confirm its existing implementation instead of challenging the intended behavior.
ELI5
Test-driven development writes the check before writing the feature. The first failing test shows that the required behavior is missing, and the developer then adds code until the test passes.
For example, before building a discount calculator, a developer writes a test showing the expected price for a sample order. The test guides the implementation and later warns if another change breaks that behavior.
Why write the test before the implementation?
A prior test clarifies expected behavior and reduces the chance that the test will be shaped to accept whatever implementation was produced.
Does test-driven development prove software is correct?
No. It verifies the cases and properties expressed by the tests, while untested requirements and environmental failures can still contain defects.


