Skip to content

Testing Implementation Standard

Purpose

The Testing Implementation Standard defines backend test expectations for future implementation work.

Test Layers

Layer Expectations
Domain tests Aggregates, value objects, policies, domain services, and events.
Application service tests Use-case orchestration, authorization context, repositories, events, and audit.
Controller tests DTO validation, response envelopes, authorization failures, and error mapping.
Repository tests PostgreSQL persistence, tenant filtering, optimistic locking, soft delete, indexes where relevant.
Migration tests Liquibase changes apply cleanly and preserve data safety.
Event tests Publication, metadata, outbox, idempotent consumers, and no ownership violations.
Security tests Keycloak token handling, Identity decisions, Billing entitlements, MFA, and tenant isolation.
Modulith tests Module boundaries, dependency direction, and forbidden imports.

Minimum Expectations

  • Every module has boundary tests.
  • Every customer-scoped repository has tenant isolation tests.
  • Every protected controller has authorization tests.
  • Every retryable command has idempotency tests where applicable.
  • Every event consumer is idempotency-tested.
  • Every migration is validated in a clean database.
  • Exception handling tests verify safe error envelopes.

Test Flow

flowchart LR
    Domain[Domain Tests]
    App[Application Tests]
    API[API Tests]
    DB[Database Tests]
    Event[Event Tests]
    Modulith[Modulith Boundary Tests]

    Domain --> App
    App --> API
    App --> DB
    App --> Event
    Event --> Modulith

Non-Goals

This document does not define test frameworks, fixtures, CI configuration, coverage thresholds, or container setup.