統合テストは、複数のコンポーネントまたはユニットが正しく連携して動作することを検証します。これらのテストは、相互作用と統合ポイント(コードとデータベースの連携、サービス間の呼び出し、モジュール結合など)をテストします。ユニットテスト(ユニットを分離してテスト)が見つけられない問題をキャッチします。
統合テストが検証すること
Integration tests verify COMPONENTS WORKING TOGETHER (not in isolation):
→ code + DATABASE (does the data layer actually work with a real DB?)
→ service A calling service B / an external API
→ multiple modules/units combined; the integration POINTS between them
→ catches issues in how parts INTERACT — which unit tests (isolated) can't catch.
統合テストが重要な理由(ユニットテストとの比較)
UNIT tests isolate units (mocking dependencies) → fast, but DON'T verify real integration:
→ a unit can pass its tests but FAIL when combined (wrong assumptions about a dependency,
a real DB query that's wrong, an API contract mismatch, config issues)
INTEGRATION tests use REAL (or realistic) dependencies → catch these interaction bugs:
→ wiring/configuration errors, data layer issues, contract mismatches between components
→ Integration tests verify the parts actually work TOGETHER.
