1 min lesson
Know when to write the test first
Choose test-driven development when expected behavior can be written before implementation.
Step 1 of 2
A test helps Agent only when it fails for the intended reason before implementation begins and stays unchanged afterward.
Use test-driven development when expected inputs and outputs can be written before the implementation. Ask Agent for tests only and tell it not to create implementation or mock functions. Run the target test and read the failure. The failing run counts only when the intended behavior fails, not setup, syntax or an import. Review and commit the tests. Then ask Agent to make those committed tests pass without changing them.
Where this fits
- Entry point
- Agent and the repository test command
- Source
- Cursor Learn, Developing features
Use the repository's real test command and follow Cursor's test-driven development sequence.