learning-it by example

Back to the video

TDD With an AI Assistant: Red, Green, Refactor (unittest)

A first draft passed all five tests and still charged minus two pounds.

Video #171 ยท AI coding and productivity

Steps in the video

  1. 0:00 A first draft passed five of five tests and still charged minus two pounds
  2. 0:35 The idea
  3. 1:12 Setup
  4. 1:46 Step one: the spec
  5. 2:18 Red
  6. 2:39 Step two: a first draft
  7. 3:07 The case the spec forgot
  8. 3:38 The fix
  9. 4:03 Step three: refactor
  10. 4:37 What this does not show
  11. 5:06 Mistakes to avoid
  12. 5:31 My take and next steps
  13. 5:56 Recap

Files

  • check.py (30 lines)
  • draft1.py (13 lines)
  • draft2.py (13 lines)
  • final.py (15 lines)
  • spec.py (26 lines)
  • stub.py (5 lines)

Download the code (zip)

Tested with

Python 3.12.15

What this does not show

No AI was run in this video: the first draft is hand-written to look like a typical assistant draft.

Sources

Learning IT by Example.