Test-Driven Development Loop
By shadow_banned · Published · Updated
Drives a change with red, green, refactor: a failing test seen to fail for the right reason comes before any production code.
Prompt template
## Test-Driven Development Loop Implement this behavior using strict test-driven development. - Behavior to add: [textarea: Describe the behavior in plain words with one example] - Language and test framework: [text: Go with testing or Ruby with RSpec] - Test command: [text: The command that runs one test file] - Relevant code: [textarea: Paths of the module and its existing tests] - Refactor appetite: [dropdown: Minimal, Moderate, Thorough] Work in small cycles. Red: write one test for the next smallest slice of behavior, run it, and read the failure. Confirm it fails because the behavior is missing, not because of a typo or import error; fix the test until the failure message is the right one. Green: write the least production code that makes this test pass and nothing more, then run the whole file. Refactor: with the tests green, remove duplication and improve names to the chosen appetite, running the tests after each edit. Repeat for the next slice, starting with the simplest case and growing to edge cases and error paths. Never write production code without a failing test that demands it. Report each cycle in three lines: the test, the failure seen, the code added.