dbt tests are SQL assertions that run against models and sources. They do not transform data; they return failing rows. Zero failing rows = pass.
Built-in (generic) tests
Usually declared in YAML next to columns:
models:
- name: fct_orders
columns:
- name: order_id
tests:
- unique
- not_null
- name: customer_id
tests:
- relationships:
to: ref('dim_customers')
field: customer_id
- name: amount
tests:
- dbt_utils.accepted_range:
min_value: 0Custom / singular tests
A SQL file under tests/ that should return 0 rows, e.g. "no shipped order without a ship date."
Commands
dbt test: run tests onlydbt build: run models and tests in DAG order so a failed upstream test can block dependents
dbt run -> build relations dbt test -> assert expectations dbt build -> run + test together (quality gate in the DAG)
Source freshness
dbt source freshness checks whether raw sources updated within warn_after / error_after windows.
Interview tip: Say dbt tests are cheap warehouse SQL checks co-located with models. List unique, not_null, relationships, plus custom SQL and source freshness.