| name | dbt-testing |
| description | Load when task involves adding, writing, or fixing dbt unit tests. Covers unit_tests YAML format, given/expect blocks, edge-case coverage, and the difference between unit tests and schema tests. |
| disable-model-invocation | false |
| allowed-tools | Bash(dbt *) |
dbt Testing Skill - Unit Tests
1. Unit Tests vs Schema Tests
Schema tests (unique, not_null, accepted_range) check constraints on output data.
Unit tests check computation logic with mock inputs and expected outputs.
When a task says "add tests," determine which type:
- "logic", "computation", "calculation", "edge cases", "verify behavior" = unit tests
- "constraints", "uniqueness", "nullability", "referential integrity" = schema tests
If the model already has schema tests and the task says "add tests," it means unit tests.
Do NOT add schema tests when the task asks to verify logic - schema tests cannot detect formula bugs like reversed signs, wrong denominators, or incorrect window sizes.
2. YAML Structure
Unit tests live in a .yml file next to the model. Top-level key is unit_tests:, NOT inside models:.
unit_tests:
-
{ , , }
{ , , }
{ , }
{ , }
{ , }