Skip to content

dbt Tests

Anything that keeps data quality as high as our assumptions allow: uniqueness of keys, nulls, non-overlapping ranges.

Test types

  • Generic: referenced by name in the model .yml. unique, not_null, accepted_values, relationships, plus dbt_utils and dbt-expectations tests
  • Singular: a SQL query returning failing rows, saved in tests/

Severity (error or warn) applies to both, with error_if and warn_if conditions, e.g. warn_if = '>0' and error_if = '>100'. See the severity docs.

Warning

In dbt Cloud jobs a warning does not notify: only errors appear as failures.

Activating tests

Legacy tests (200+) are not run because their assumptions may be outdated. Only models with the TestsEnabled tag run tests. Add the tag on the model, not on the tests.

dbt test --select <your_model_name>
dbt test --select tag:TestsEnabled

When enabling a model, evaluate its legacy tests and fix or remove them.

Monitoring

dbt test --select tag:TestsEnabled runs daily at 7am UTC in the Prod Test Run job. Enable email notifications on failure under Settings > Notification Settings > Email Notifications.