🧪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.
Phase 1The Wrong Prompt and the Right One
Why 'write tests for this' is the wrong prompt
AI tests memorize your bugs, they don't catch them
6 minAI tests memorize your bugs, they don't catch them
Boundaries first, branches second, oracle last
7 minBoundaries first, branches second, oracle last
Feed the model the spec, not the code
7 minFeed the model the spec, not the code
Tautology tests pass forever — and prove nothing
6 minTautology tests pass forever — and prove nothing
Phase 2Boundaries, Branches, and One Nasty Edge
Drive AI to boundaries, errors, and nasty edge cases
Make the AI list every input boundary before writing one test
7 minMake the AI list every input boundary before writing one test
Every if statement is a missed test waiting to happen
7 minEvery if statement is a missed test waiting to happen
Test what's always true, not what should happen this time
7 minTest what's always true, not what should happen this time
If a deliberate bug doesn't break a test, the test is fake
8 minIf a deliberate bug doesn't break a test, the test is fake
Ask the AI what would humiliate the function in front of its peers
7 minAsk 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
You drive, AI navigates — never the other way around
6 minYou drive, AI navigates — never the other way around
The model is great at green, dangerous at red
7 minThe model is great at green, dangerous at red
Review AI-generated tests harder than your own
7 minReview AI-generated tests harder than your own
Make your prompt sequence a checklist, not a habit
6 minMake your prompt sequence a checklist, not a habit
Phase 4Catch a Planted Bug
Catch a planted bug with an AI-built test suite
Take a real function, plant a bug, build a suite that catches it
18 minTake 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.
Related paths
🐍Python Decorators Introduction
Build one mental model for Python decorators that covers closures, argument passing, functools.wraps, and stacking — then ship a working caching or logging decorator from scratch in under 30 lines.
🦀Rust Lifetimes Explained
Stop reading `'a` as line noise and start reading it as scope arithmetic — one failing snippet at a time — until you can thread lifetimes through a small parser or iterator adapter without fighting the borrow checker.
☸️Kubernetes Core Concepts
Stop drowning in 30+ resource types. Build the mental model one primitive at a time -- pods, deployments, services, ingress, config -- then deploy a real app with rolling updates and health checks.
📈Big O Intuition
Stop treating Big O as math you memorized for an interview — build the intuition to spot O(n²) disasters, pick the right data structure without thinking, and rewrite a slow function from O(n²) to O(n) in under five minutes.