GuideBeginner

Testing Fundamentals and TDD

Learn to test software from the ground up: what makes a test good, and the TDD cycle (red-green-refactor), hands-on with pure domain logic in Python using `pytest`. You start by writing tests by hand with `assert`, no framework at all, so the concept sticks before any tool automates it away; then you install `pytest` and practice the test-first rhythm until writing the test first starts to change how you design your code. The guide covers equivalence classes and boundary values, `pytest.raises` for exceptions, `@pytest.mark.parametrize` for case tables, tests that read well and don't break, coverage with `coverage.py` (and why 100% isn't the goal), and closes by teaching you to smell a test that's getting in the way and to control your first dependency with a simple test double. The whole path works on Reservo, a coworking room-booking system made of pure in-memory logic (no database, no network) — the perfect ground to practice on without infrastructure getting in the way. It closes with a final project where you build Reservo's cancellation-and-refund policy from scratch with TDD.

64
lessons
8
modules
English · Spanish
available in
Yes
certificate
Free
access
NIEVA

Outcomes

What you'll be able to do

  • Define what makes a test good (fast, isolated, deterministic, readable), and write tests by hand with `assert` before ever touching a framework
  • Install and use `pytest`: test discovery, assertions, running subsets with `-k`/`-x`/`-q`, and reading red/green output
  • Practice the full TDD cycle (red-green-refactor) test-first, seeing how writing the test first changes your code's design
  • Cover cases and edges with equivalence classes, boundary values, `pytest.raises` for exceptions, and `@pytest.mark.parametrize` for case tables
  • Write tests that read well and don't break: names that document, the Arrange-Act-Assert pattern, one concept per test, and basic `pytest` fixtures
  • Measure and read coverage with `coverage.py`/`pytest --cov` without turning it into a fetish, understanding what coverage does NOT see
  • Recognize test smells (testing implementation, over-testing, slow or non-deterministic tests) and use your first test double (a `Clock`/stub) to control time
  • Apply TDD end to end on a real project: build Reservo's cancellation-and-refund policy, from red to green to refactor

Before you start

What you need to bring

It's for you if...

  • Python devs who have never written a test, or write them "because it's required," without understanding what makes one good
  • Devs who want to learn TDD with discipline, practicing the red-green-refactor cycle step by step
  • Teams that run `pytest` without fully mastering it (test discovery, `parametrize`, basic fixtures)
  • Devs chasing 100% coverage without knowing what it actually measures and what it misses

Requirements and materials

  • Basic Python knowledge (functions, exceptions, classes, lists and dictionaries)
  • Python 3.10+ installed locally (this guide was verified with Python 3.14 and pytest 9.1.1)
  • No prior testing or `pytest` knowledge required — the guide starts from zero

Content

The syllabus, module by module

Open any of them to see its lessons.

Common questions

What people usually ask

Start whenever you like

Reviews

What students say

These reviews are from enrolled students who completed at least 50% of the course. We moderate reviews only on content grounds (spam, offensive language, personal data), never for being critical or negative.

No approved reviews yet.

Be the first to share your experience!