Test-Driven Development
Question
Explain TDD, have you used it?
Short interview answer
Test-driven development (TDD) means writing a failing automated test for the next required behavior, implementing the smallest change that makes it pass, then improving the code while keeping the tests passing.
Detailed answer
TDD uses the test as an executable statement of behavior. Suppose a pricing rule must reject a negative quantity: first add a test that expects that result, run it and observe failure, then implement only the validation needed to pass. Refactor afterwards if the code or test can be clearer. This loop is useful when it leads to fast, isolated tests and a better API, but it does not replace integration testing, exploratory testing, or production monitoring. A test suite is valuable when it checks observable behavior rather than merely mirroring implementation details.
Glossary
- TDD: Test-driven development.