Back to library

🧪Use AI to Generate Tests

Turn AI from a happy-path test generator into a real partner that probes boundaries, error paths, and oracle gaps — so the suite catches bugs instead of memorizing them.

Foundations14 drops~2-week path · 5–8 min/daytechnology

Phase 1The Wrong Prompt and the Right One

Why 'write tests for this' is the wrong prompt

4 drops
  1. AI tests memorize your bugs, they don't catch them

    6 min

    AI tests memorize your bugs, they don't catch them

  2. Boundaries first, branches second, oracle last

    7 min

    Boundaries first, branches second, oracle last

  3. Feed the model the spec, not the code

    7 min

    Feed the model the spec, not the code

  4. Tautology tests pass forever — and prove nothing

    6 min

    Tautology tests pass forever — and prove nothing

Phase 2Boundaries, Branches, and One Nasty Edge

Drive AI to boundaries, errors, and nasty edge cases

5 drops
  1. Make the AI list every input boundary before writing one test

    7 min

    Make the AI list every input boundary before writing one test

  2. Every if statement is a missed test waiting to happen

    7 min

    Every if statement is a missed test waiting to happen

  3. Test what's always true, not what should happen this time

    7 min

    Test what's always true, not what should happen this time

  4. If a deliberate bug doesn't break a test, the test is fake

    8 min

    If a deliberate bug doesn't break a test, the test is fake

  5. Ask the AI what would humiliate the function in front of its peers

    7 min

    Ask the AI what would humiliate the function in front of its peers

Phase 3AI as a Junior Pair in TDD

Use AI as a junior pair inside red-green-refactor

4 drops
  1. You drive, AI navigates — never the other way around

    6 min

    You drive, AI navigates — never the other way around

  2. The model is great at green, dangerous at red

    7 min

    The model is great at green, dangerous at red

  3. Review AI-generated tests harder than your own

    7 min

    Review AI-generated tests harder than your own

  4. Make your prompt sequence a checklist, not a habit

    6 min

    Make your prompt sequence a checklist, not a habit

Phase 4Catch a Planted Bug

Catch a planted bug with an AI-built test suite

1 drop
  1. Take a real function, plant a bug, build a suite that catches it

    18 min

    Take a real function, plant a bug, build a suite that catches it

Frequently asked questions

Why do AI-generated tests miss real bugs?
This is covered in the “Use AI to Generate Tests” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
What should I prompt instead of 'write tests for this function'?
This is covered in the “Use AI to Generate Tests” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
How do I check if AI tests actually catch anything?
This is covered in the “Use AI to Generate Tests” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Can I use AI inside test-driven development?
This is covered in the “Use AI to Generate Tests” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
How is this different from just using Copilot?
This is covered in the “Use AI to Generate Tests” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.