Tests#
Note
The below checks require manifest.json to be present.
Checks related to model test coverage and test configuration.
Functions:
| Name | Description |
|---|---|
check_model_has_unique_test |
Models must have a test for uniqueness of a column. |
check_model_has_unit_tests |
Models must have more than the specified number of unit tests. |
check_model_test_coverage |
Set the minimum percentage of models that have at least one test. |
check_model_has_unique_test
#
Models must have a test for uniqueness of a column.
Rationale
A uniqueness test is the most fundamental data quality check — it ensures that the primary key or identifier column of a model does not contain duplicates, which would cause incorrect counts and fan-out in downstream joins. This check enforces that no model reaches production without at least one uniqueness assertion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
accepted_uniqueness_tests
|
list[str] | None
|
List of tests that are accepted as uniqueness tests. |
['dbt_expectations.expect_compound_columns_to_be_unique', 'dbt_utils.unique_combination_of_columns', 'unique']
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
model |
ModelNode
|
The ModelNode object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
materialization |
Literal[ephemeral, incremental, table, view] | None
|
Limit check to models with the specified materialization. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
manifest_checks:
# Example of allowing a custom uniqueness test
- name: check_model_has_unique_test
accepted_uniqueness_tests:
- dbt_expectations.expect_compound_columns_to_be_unique # i.e. tests from packages must include package name
- my_custom_uniqueness_test
- unique
Source code in src/dbt_bouncer/checks/manifest/models/tests.py
check_model_has_unit_tests
#
Models must have more than the specified number of unit tests.
Rationale
Unit tests validate a model's transformation logic with controlled, mock inputs rather than real warehouse data. Requiring them on critical models (e.g. marts) ensures that complex SQL logic is verified independently of data volume or state, catching regressions before they affect downstream consumers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_number_of_unit_tests
|
int | None
|
The minimum number of unit tests that a model must have. |
1
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
manifest_obj |
ManifestObject
|
The ManifestObject object parsed from |
model |
ModelNode
|
The ModelNode object to check. |
unit_tests |
list[UnitTests]
|
List of UnitTests objects parsed from |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
materialization |
Literal[ephemeral, incremental, table, view] | None
|
Limit check to models with the specified materialization. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Warning
This check is only supported for dbt 1.8.0 and above.
Example(s):
Source code in src/dbt_bouncer/checks/manifest/models/tests.py
check_model_test_coverage
#
Set the minimum percentage of models that have at least one test.
Rationale
Rather than requiring every model to be tested immediately, this check lets teams set a realistic coverage target and enforce it progressively. It prevents test coverage from silently declining as new, untested models are added to the project, creating a ratchet towards comprehensive testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_model_test_coverage_pct
|
float
|
The minimum percentage of models that must have at least one test. |
100
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
models |
list[ModelNode]
|
List of ModelNode objects parsed from |
tests |
list[TestNode]
|
List of TestNode objects parsed from |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):