# dbt Test

> A check that dbt runs on a table. It passes when no row breaks the rule.

**Field:** Data Engineering  
**Category:** Processing  
**Also known as:** dbt Data Test, dbt Tests, data_tests

## Think of it like

It is like a spell checker that runs after you type. It points at each word that breaks a rule.

## Definition

A dbt test is a check that dbt runs on the data in a model, a source or a snapshot. Each test is a SQL query that looks for rows that break a rule. If the query finds no rows, the test passes. dbt comes with four ready-made tests: unique, not_null, accepted_values and relationships. You add them to a column in a YAML file, then run dbt test.

## Example

Emma adds unique and not_null to the order_id column. One night a load repeats 14 orders. The unique test fails before anyone sees a report.

## Example code

```yaml
models:
  - name: orders
    columns:
      - name: order_id
        data_tests:
          - unique
          - not_null
```

Two ready-made tests on one column. dbt test runs them both.

## Why it matters

Bad data is caught where it starts. A manager does not find an odd number weeks later.

## Common mistake

Testing only the final tables. A problem is easier to find at the source, where it first gets in.

## Three principles

- **A query for bad rows.** Zero rows found means a pass.
- **Four built in.** unique, not_null, accepted_values, relationships.
- **Run every time.** Test after each build, not now and then.

## Related terms

- [dbt (Data Build Tool)](https://learn.benibix.com/term/data/dbt)
- [dbt Model](https://learn.benibix.com/term/data/dbt-model)
- [Data Quality Check](https://learn.benibix.com/term/data/data-quality-check)
- [Data Quality](https://learn.benibix.com/term/data/data-quality)
- [dbt Source](https://learn.benibix.com/term/data/dbt-source)
- [dbt Snapshot](https://learn.benibix.com/term/data/dbt-snapshot)

![A dbt project from left to right. A source, the raw table shop.orders loaded by other tools, feeds a model called stg_orders, a SELECT that cleans it. That feeds a highlighted incremental model called orders, where each run adds only the new rows. Under it, tests check that order_id is unique and not null, find 0 failing rows and pass. Under the source, a snapshot called orders_snapshot keeps each old version with valid from and to dates.](https://learn.benibix.com/diagrams/dat-dbt-project.svg)

---

Source: https://learn.benibix.com/term/data/dbt-test
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
