tdd-testing-patterns

Installation
SKILL.md

Testing Patterns

These are the hands-on techniques for writing tests. Keep the red/green/refactor rhythm by shrinking tests that are too big; replace expensive or awkward collaborators with simple stand-ins; let the test itself observe communication; force rare errors deliberately; and leave each session in the right state for whoever comes next.

Child Test

Question: How do you get a test case running that turns out to be too big? Answer: Write a smaller test for the broken part, get it running, then reintroduce the big one.

  • The red/green/refactor rhythm is worth extra effort to protect; even ten minutes red is a warning.
  • First learn the lesson: why was it too big, what would have made it smaller?
  • Then delete or disable the big test, write child tests for A, B and C, make them pass, and bring the parent back.
  • Keeping both the parent and the child red for a few minutes is possible; notice whether it changes how you work and choose accordingly.

Mock Object

Question: How do you test an object that relies on an expensive or complicated resource? Answer: Create a fake version of the resource that answers with constants.

Installs
1
First Seen
2 days ago