Skip to content

Database Testing Standard

Purpose

The Database Testing Standard defines how future database specifications and migrations must be verified.

Test Types

Test Type Purpose
Migration tests Verify Liquibase changes apply cleanly.
Repository tests Verify module-owned persistence behavior.
Tenant isolation tests Verify tenant and OrganizationId filtering.
Constraint tests Verify keys, uniqueness, and required fields.
Audit tests Verify audit columns and traceability are populated.
Optimistic locking tests Verify concurrent updates are protected.
Soft delete tests Verify deleted records are excluded or included intentionally.
Outbox tests Verify transactional event record creation.
Read model tests Verify projection ownership, staleness, and rebuild assumptions.

Minimum Acceptance Criteria

  • A module cannot write another module's owned table.
  • Tenant-scoped queries do not return cross-tenant records.
  • Required audit columns are populated on material changes.
  • Optimistic locking prevents lost updates where required.
  • Migrations are repeatable in clean environments.
  • Destructive migrations are reviewed and explicitly approved.
  • Outbox writes occur in the same transaction as source changes where required.

Test Flow

flowchart LR
    Spec[Database Spec]
    Migration[Migration]
    Repository[Repository Test]
    Tenant[Tenant Test]
    Boundary[Module Boundary Test]
    Release[Release Candidate]

    Spec --> Migration
    Migration --> Repository
    Repository --> Tenant
    Tenant --> Boundary
    Boundary --> Release

Non-Goals

This document does not define test framework code, containers, fixtures, CI jobs, data generators, or coverage thresholds.