GuideIntermediate

Contract and Integration Testing

Learn two disciplines that pick up right where unit tests with doubles leave off: contract testing (verifying that two components that talk to each other agree on their contract, consumer/provider) and integration testing (verifying that components actually work TOGETHER, crossing the seam, against real resources). The thread running through it: a green unit test can hide a broken integration, because the double was lying. Working on the Reservo case extended with a real SQLite-backed `BookingRepository` (alongside the familiar fake), you'll practice writing a consumer-driven contract test that runs the same battery against the fake and against the real implementation, verifying the contract from both sides (consumer and provider), and writing integration tests that cross the system's real boundaries — a SQLite transaction, a file, a minimal HTTP boundary — deciding what to keep real and what to double. It closes with data isolation in integration testing (transaction rollback, temporary resources) and a final project that combines a contract verified against both implementations with a full integration test of the `BookingService`.

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

Outcomes

What you'll be able to do

  • Understand why a green unit test can hide a broken integration, and where contracts and integration fit in the test pyramid
  • Recognize when a double (fake/stub) DIVERGES from the real component, and how that bug passes the unit test but blows up in production
  • Write a consumer-driven contract test: a shared spec that runs the same battery of tests against the fake and against the real implementation
  • Verify a contract from both sides — the consumer test ("I send X, I expect Y") and the provider test ("given X, I return Y") — to catch breaking changes before deployment
  • Write integration tests that cross the seam for real, deciding what to keep real and what to double in an integration test
  • Test at the system's real boundaries: a SQLite transaction, a file, a minimal HTTP call, keeping those tests fast and deterministic
  • Isolate data and state in integration testing: transaction rollback, real-resource fixtures (creating and tearing down a temporary database), independent and repeatable tests
  • Combine contract and integration testing on a real case: verify a repository against its fake and its SQLite implementation, and test the full service against the real repository

Before you start

What you need to bring

It's for you if...

  • Devs who already use test doubles comfortably and want to verify those doubles aren't lying about real behavior
  • Teams with more than one service or component talking to each other that need to catch broken contracts before deployment
  • Devs who want to move from "unit test with a fake" to "test against a real database and HTTP boundary" without adopting a full web framework yet
  • Devs laying the groundwork to test a real backend app (FastAPI, a production database) later on

Requirements and materials

  • Test Doubles and Test Data guide completed (or equivalent: knowing how to use and build a fake, a stub, a mock)
  • Testing Fundamentals and TDD guide completed (or equivalent: pytest, the TDD cycle, fixtures)
  • Python 3.14 and pytest 9.1.1 installed locally (`sqlite3` and `http.server` are part of the standard library; Pact is treated as a concept, not installed)

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!