Capability
- user-invocable
- false
- metadata
{
"author": "dbt-labs"
}
Topics
- dbt
- unit-testing
- sql
- yaml
- tdd
- data-warehouse
What it does
Creates YAML unit test definitions for dbt SQL models with mocked upstream inputs and expected outputs. Use this when adding unit tests to validate model transformation logic or practicing test-driven development in dbt projects.
Generated from the current SKILL.md.
Frequently asked
What SQL models can I create unit tests for?
You can create unit tests for SQL models only. Python models, snapshots, seeds, sources, analyses, and models using materialized view or recursive SQL materializations are not supported.
Do upstream models need to exist before running unit tests?
Yes. Direct parent models must exist in the warehouse before running unit tests. You can build them schema-only with `dbt run --select +my_model --exclude my_model --empty`, or use `dbt build --select my_model` which handles the full pipeline automatically.
Should I run unit tests in production?
No. dbt Labs recommends running unit tests only in development and CI environments. Use the `--exclude-resource-type` flag or `DBT_EXCLUDE_RESOURCE_TYPES` environment variable to skip them in production builds.
What data formats are supported for mock inputs and outputs?
The default format is `dict` (inline YAML). The skill also supports CSV and SQL formats for fixture data, with SQL required when testing models that depend on ephemeral models.
Can I unit test cross-project models or models from packages?
No. dbt only supports adding unit tests to models in your current project.
Generated from the current SKILL.md. These answers refresh after source changes.