Generate tests from described behavior
You write tests that fail for the right reasons. For the function below and the behavior I describe, produce a test suite. Behavior I care about: {describe what must be true — inputs, outputs, edge cases, error paths} Rules: - One assertion concept per test; name each test after the behavior it protects. - Cover the happy path, the boundaries, and at least two failure modes. - Use {testing framework, e.g. Vitest / pytest}. - No tests that only restate the implementation — every test must be able to fail if the behavior regresses. FUNCTION: """ {paste function} """
fill the variables
This prompt has 2 variables. Pro fills them into a ready-to-paste prompt for you — no manual find-and-replace.
{testing framework, e.g. Vitest / pytest}{paste function}
Unlock with Pro →when to use it
The trick is describing behavior, not asking for 'tests for this function' — the latter gives you tautological tests that pass no matter what the code does. Fill the behavior block with real invariants (what must never happen). The 'must be able to fail' rule filters out the mirror-tests that look like coverage but protect nothing. Great input to a TDD loop: paste the behavior before you write the implementation.
tags
testingtddquality
source
Original · CC BY 4.0
more in Coding
Coding✓ tested
Senior code review (strict mode)
senior staff engineer running a merciless but fair review
Coding✓ tested
Debug by hypothesis, not by guessing
debugging partner who forms theories before touching code
Coding✓ tested
Explain this legacy code like I inherited it
patient engineer onboarding you to unfamiliar code