Add tests: boundaries first
List boundary conditions, then give runnable test cases
Prompt
Copy it whole, then replace the brackets with your own contentHandle this code task: Add tests - cover the boundaries first. Code or error: [paste] Environment: [language/version/framework] Requirements: list the boundary conditions, then give runnable test cases. Give the assessment first, then the changes, then how to verify.
Replace the text in [ ] with your own situation; ask long tasks in stages.
How to get better results
Read this before you fill it inLegacy code needs changes but has no tests; add guardrails first, then modify.
Give the conclusion and impact scope first, then only the changed snippets (no full files), and finally one check that proves it works. Flag risky spots separately.
Add tests to this price-calculation function, covering first: 0 items, negatives, stacked discounts, decimal rounding. Use PHPUnit.
"Write some tests" yields assertions that just restate the implementation No boundaries specified, so invalid inputs are missed Not requiring runnable code, so it will not run
If problems remain after the fix, paste the new error and the changed snippet back; keep debugging on the original approach, don't switch approaches and rewrite.
More like this: Writing code prompts · All prompts