Caffeinated Coder
Book an appointment
Lesson 37 · Tools of the trade

Unit testing

A unit test runs one small piece of code with input whose right answer you already know, and checks the output with an assertion. Follow test_add as it calls add(2, 3), see pytest run every test in a second, catch a broken change straight away, and grow the code test-first: red, green, refactor.

10 min12 steps5 questionsIntermediate
Fig 37 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.