# Testing Strategy

Purpose: define test layers, quality gates, and responsibilities by phase.

---

## Test Pyramid

1. Unit tests: fast, isolated, behavior-focused.
2. Integration tests: app-to-app and adapter boundary flows with real DB where needed.
3. Contract tests: REST and event payload compatibility.
4. End-to-end tests: critical business paths only.
5. Non-functional tests: load, resilience, and chaos scenarios.

---

## Phase-Aligned Test Focus

| Phase | Primary Test Focus | Status |
|-------|--------------------|--------|
| Phase 0 | Build validation, smoke tests, repo health | ✅ 16 tests, 0 failures (2026-04-26) |
| Phase 1 | Auth, routing, adapter_banking sync flow | 🚧 In Progress |
| Phase 2 | Broadway async pipeline, DLQ behavior, replay safety | ⏳ Pending |
| Phase 3 | WebSocket auth, topic authorization, push latency | ⏳ Pending |
| Phase 4 | Admin authorization, route edits, live data accuracy | ⏳ Pending |
| Phase 5 | Mobile payload contract, push delivery reliability | ⏳ Pending |
| Phase 6 | Load, failover, chaos, SLO compliance | ⏳ Pending |

---

## Minimum Quality Gates

1. compile with warnings-as-errors: required.
2. static checks (format and credo): required.
3. unit and integration test suites: required.
4. contract tests: required for changed endpoints/events.
5. coverage threshold for changed modules: 80 percent minimum.

---

## Critical Regression Suite

Always run before merge on affected areas:

1. POST /api/v1/transactions success and auth failure path.
2. Route resolution and circuit breaker open path.
3. File pipeline malformed row to DLQ path.
4. WebSocket transaction status_update delivery.
5. Audit record write with trace_id.

---

## Test Data and Fixtures

1. Use sanitized, non-production fixture data only.
2. Keep schema fixtures versioned with contracts.
3. Reset DB state between integration tests.

---

## Ownership

- QA Team: integration, contract, and regression suites.
- Engineering Teams: unit tests and feature-level integration tests.
- Platform Team: CI execution model and quality gate enforcement.
