MODULE 11 · INTERMEDIATE

Advanced Testing PracticesPython · Module 11

Drive design with tests, isolate external boundaries with test doubles, and make coverage and CI tell the truth about what is verified.

4 lessons16 min readingBuild reliable programs1 project
Free, self-paced, and open to everyone. No account needed.
WHAT THIS MODULE COVERS

Advanced Testing Practices

Drive design with tests, isolate external boundaries with test doubles, and make coverage and CI tell the truth about what is verified.

BEFORE YOU START

Basic pytest experience and function knowledge.

WHAT YOU’LL BE ABLE TO DO

Practice test-driven development (TDD), use mocking to isolate units, measure test coverage, and configure CI/CD pipelines for automated testing.

THE LESSON SEQUENCE

Read in order, or jump to what you need.

Every lesson builds on the one before it. Open any lesson to read the explanation, run the examples, and try the practice challenges.

  1. 11.01
    Test-Driven Development

    Use the red-green-refactor cycle to design interfaces from behavior and keep refactoring safe.

    4 min
  2. 11.02
    Mocking and Patching

    Replace external boundaries with test doubles, verify interactions, and avoid mocks that hide real integration failures.

    4 min
  3. 11.03
    Test Coverage and CI

    Measure what the suite executes, set meaningful thresholds, and run the same checks automatically on every change.

    4 min
  4. 11.04
    Project: A Tested Payment ServiceProject

    Drive a payment service with a failing test, isolate the gateway behind a Protocol, make retries idempotent, and enforce coverage in CI.

    4 min
MODULE SELF-CHECK

Ready to move on?

Write a failing test first, implement the feature to pass it, add mocks for external dependencies, and verify 80%+ test coverage.

Open the module self-check