Test configurations

Related documentation

Changelog

Tests can be configured in a few different ways:

  1. Properties within .yml definition (generic tests only, see test properties for full syntax)
  2. A config() block within the test's SQL definition
  3. In dbt_project.yml

Test configs are applied hierarchically, in the order of specifity outlined above. In the case of a specific instance of a generic test, the test's .yml properties would take precedence over any values set in its generic SQL definition's config(), which in turn would take precedence over values set in dbt_project.yml.

tests/<filename>.sql
{{
config(
enabled = true | false,
severity = 'error' | 'warn',
tags = 'example_tag' | ['example_tag_1', 'example_tag_2']
)
}}
dbt_project.yml
tests:
+enabled: true | false
+severity: error | warn
+tags: <string> | [<string>]

Examples

Add a tag to one test

If a specific instance of a generic test:

models/<filename>.yml
models:
- name: my_model
columns:
- name: id
tests:
- unique:
tags: ['my_tag']

If a bespoke test:

tests/<filename>.sql
{{ config(tags = ['my_tag']) }}
select ...

Set the default severity for all instances of a generic test

macros/<filename>.sql
{% test my_test() %}
{{ config(severity = 'warn') }}
select ...
{% endtest %}

Disable all tests from a package

dbt_project.yml
tests:
package_name:
+enabled: false