集成测试验证多个组件或单元是否正确协同工作 — 测试交互和集成点(如代码与数据库、服务相互调用或模块组合)。它捕获单元测试(隔离单元)遗漏的问题。
集成测试验证什么
text
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.
集成测试为何重要(相比单元测试)
text
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.
