adding-dbt-unit-test

Create dbt unit test YAML definitions that mock upstream model inputs and validate expected outputs.

1|Updated Apr 6, 2026
One-click install
npx skills add https://github.com/pkoka888/server-infra-templates --skill adding-dbt-unit-test-pkoka888
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adding-dbt-unit-test
Source: https://github.com/pkoka888/server-infra-templates/tree/main/.kilo/skills/marketplace/dbt/skills/adding-dbt-unit-test
Command: npx skills add https://github.com/pkoka888/server-infra-templates --skill adding-dbt-unit-test-pkoka888

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps engineers and analysts create reproducible dbt unit test definitions that mock upstream model inputs and assert expected outputs, reducing the risk of regressions and enabling test-driven development for SQL models.

Core Features & Use Cases

  • Mocked Inputs and Expected Outputs: Define given inputs for refs, sources, and seeds and declare the expected rows for the model under test.
  • Multiple Fixture Formats: Support for inline dict, csv, and sql formats as well as external fixture files in test-paths.
  • Special Case Handling: Guidance for incremental models, ephemeral dependencies, versioned models, and adapter-specific caveats for BigQuery, Redshift, Snowflake, Postgres, and Spark.
  • Overrides and Environment Control: Ability to override macros, project vars, and environment variables for precise test scenarios.
  • Use Case: Add unit tests for complex transformations (regex, window functions, multi-join logic) or validate bug fixes before materializing models.

Quick Start

Add a unit test YAML entry that names the test, points at the model, supplies given inputs for each upstream ref or source, and lists the expected rows for the model's output.

Frequently Asked Questions about adding-dbt-unit-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write dbt unit tests for SQL models?

You can create dbt unit tests by generating YAML entries that supply mocked inputs for upstream refs and sources alongside the expected output rows. This approach validates SQL transformations like window functions and multi-join logic using inline dict, csv, or sql fixture formats.

What fixture formats are supported for dbt unit tests?

dbt unit tests support inline dict, csv, and sql fixture formats for mocking inputs. You can also reference external fixture files stored in your configured test-paths directory to organize and reuse test data across multiple unit test definitions.

Can I test incremental and ephemeral dbt models with unit tests?

Yes, you can test incremental and ephemeral dbt models using unit test YAML definitions. The framework provides specific guidance for handling incremental dependencies, ephemeral models, versioned models, and adapter-specific caveats for BigQuery, Snowflake, Redshift, Postgres, and Spark.

How do I override macros and variables in dbt unit tests?

dbt unit tests allow you to override macros, project vars, and environment variables directly within the YAML definitions. This environment control enables you to create precise test scenarios and validate bug fixes before materializing your models.

When should I use dbt unit tests instead of standard schema tests?

Use dbt unit tests when you need to validate complex transformation logic like regex, window functions, or multi-join operations by mocking inputs and asserting exact expected outputs. Standard schema tests check data quality constraints, whereas unit tests enable test-driven development for specific SQL model behaviors.

How do I practice TDD with dbt SQL models?

To practice TDD with dbt, write unit test YAML definitions that specify mocked upstream inputs and expected outputs before or during SQL model development. This test-driven approach reduces regression risk by validating transformation logic against edge cases as you code.