dbt tests can dramatically reduce breakages — but only if they are chosen and operated carefully. Too few tests and you miss real issues; too many expensive tests and teams stop running them.
Baseline tests for every model
- unique + not_null on primary keys
- not_null on critical foreign keys
- accepted_values for enums that drive logic
Add pipeline-level checks
Row-count anomalies and freshness checks catch upstream outages. Even simple thresholds outperform ‘green job == good data’.
Keep tests fast
- Prefer column-level tests that scan fewer bytes.
- Partition big tables so tests can run on recent partitions.
- Move expensive reconciliations to scheduled jobs.
yamlversion: 2 models: - name: mart_orders columns: - name: order_id tests: [unique, not_null] - name: status tests: - accepted_values: values: ['created','paid','shipped','refunded']
Operate tests like production
When a test fails, the workflow should be clear: who triages, how to rerun, and how to fix upstream. Add alert routing and dashboards for failing tests over time.
