Integration Testing - Testing Module Interactions
What integration tests cover
Section titled “What integration tests cover”Integration tests verify interactions between units.
Examples:
- repository ↔ database
- API client ↔ real HTTP server (or test server)
- service ↔ message queue
When integration tests are valuable
Section titled “When integration tests are valuable”- you want confidence in boundary behavior
- you’re worried about schema changes
- you use third-party APIs/libraries
Diagram: integration boundary
Section titled “Diagram: integration boundary”graph LR A[Business logic] --> B[Repository] B --> C["(Database)"] A --> D[HTTP client] D --> E[External API]
- Keep them fewer than unit tests
- Use test databases/containers where possible
- Make setup/teardown reliable
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – Write a unittest TestCase
Section titled “Exercise 1 – Write a unittest TestCase”Exercise 2 – assertRaises
Section titled “Exercise 2 – assertRaises”Exercise 3 – setUp and tearDown
Section titled “Exercise 3 – setUp and tearDown”pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading