Database sharing occurs when multiple applications access the same database. It couples systems and complicates independent development, so APIs or message buses are preferable whenever feasible. section 8.2
When a shared database is unavoidable:
- Treat tables visible to other applications as an unmanaged dependency; their rows effectively act as messages. section 8.2
- Mock interactions with shared tables to preserve the existing communication pattern, and avoid changing them unless absolutely necessary. section 8.2
- Treat application-only tables as a managed dependency and verify the database’s final state rather than interactions. section 8.2
Figure 8.5. Treat the part of the database that is visible to external applications as an unmanaged dependency. Replace it with mocks in integration tests. Treat the rest of the database as a managed dependency. Verify its final state, not interactions with it.
Use the database boundary diagram to distinguish externally visible tables from application-owned tables and select the corresponding integration-test strategy. section 8.2
