API Integration & Contract Testing
Test a service against a real PostgreSQL database and verify that the running implementation honors its published API contract.
4 objectives 6 steps about 125 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Run integration tests against a disposable PostgreSQL instance with migrations applied and per-test isolation through transaction rollback or truncation.
- Write end-to-end API tests that exercise authentication, persistence and error paths through the HTTP layer, building test data with factories.
- Check the implementation against its OpenAPI contract with schema-based tests, and explain where consumer-driven contract tests fit.
- Keep the suite fast and deterministic by controlling time and randomness, faking external HTTP services and isolating flaky tests.
Lesson plan
6 steps, about 125 min · 5 of 5 lessons available so far
- Why Mocks Lie About Databases Concept · 15 min
- Lab: A Disposable PostgreSQL for Every Test Run Lab · 30 min
- End-to-End API Tests with Factories Worked example · 25 min
- Contract Tests Generated from an OpenAPI Document Worked example · 25 min
- Fast, Deterministic, Not Flaky Concept · 15 min
- Check: Diagnose the Failing Suite Knowledge check · 8 questions
Practise it
Build a pytest suite that starts PostgreSQL in a container, applies Alembic migrations once per session, isolates each test in a rolled-back transaction, covers a sign-up, create, list and forbidden-access flow over HTTP, and runs a schema-based contract check against the app's OpenAPI document.
References
Hard prerequisites
Unlocks
Nothing depends on this skill yet.
On these roadmaps
Progress and evidence for this skill are shared across all of them.