Loading lesson…
Writing a test first is not just good engineering. It is the clearest possible prompt for an AI. Let's use tests to make AI code reliable.
A test says: when I give the function this input, I expect exactly this output. That is the most precise way to describe behavior that exists. If you paste a failing test and ask the AI to make it pass, you get amazingly focused results.
# Step 1: write the tests first
def test_add_positive():
assert add(2, 3) == 5
def test_add_negative():
assert add(-1, -1) == -2
def test_add_zero():
assert add(0, 42) == 42
# Step 2: paste the tests into your AI chat and say:
# "Write the `add` function so all three tests pass."
# Step 3: the AI almost always produces:
def add(a, b):
return a + b
# Step 4: run pytest. If green, ship it.Writing the tests first gives the AI an unambiguous target. No room for misinterpretation.You do not need to write every test by hand. Give the AI the function signature, ask for test cases including edge cases, then review the list. You will often find a case you had not considered — that is the point.
| Language | Framework | Command |
|---|---|---|
| Python | pytest | pytest |
| TypeScript | Vitest | npx vitest |
| JavaScript | Jest | npm test |
| Go | testing (built-in) | go test ./... |
| Rust | cargo test | cargo test |
Tests are the only prompt that runs.
— A TDD-loving engineer
The big idea: a test is a prompt the machine can verify. Writing tests first turns every AI coding session into a tight loop: target, generate, check, done.
15 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-coding-tests-as-prompts-builders
What is the core idea behind "Tests as Prompts — an Unexpected Superpower"?
Which term best describes a foundational idea in "Tests as Prompts — an Unexpected Superpower"?
A learner studying Tests as Prompts — an Unexpected Superpower would need to understand which concept?
Which of these is directly relevant to Tests as Prompts — an Unexpected Superpower?
Which of the following is a key point about Tests as Prompts — an Unexpected Superpower?
Which of these does NOT belong in a discussion of Tests as Prompts — an Unexpected Superpower?
What is the key insight about "The edge case checklist" in the context of Tests as Prompts — an Unexpected Superpower?
What is the key insight about "Do not let the AI write tests that test nothing" in the context of Tests as Prompts — an Unexpected Superpower?
Which statement accurately describes an aspect of Tests as Prompts — an Unexpected Superpower?
What does working with Tests as Prompts — an Unexpected Superpower typically involve?
Which of the following is true about Tests as Prompts — an Unexpected Superpower?
Which best describes the scope of "Tests as Prompts — an Unexpected Superpower"?
Which section heading best belongs in a lesson about Tests as Prompts — an Unexpected Superpower?
Which section heading best belongs in a lesson about Tests as Prompts — an Unexpected Superpower?
Which section heading best belongs in a lesson about Tests as Prompts — an Unexpected Superpower?