Skip to content
Back to skills

1008 Special Case Overrides 8f909542

ASecurity

When configuring your unit test, you can override the output of macros, project variables, or environment variables for a given unit test. `models/schema.yml` ```yml - name: test_my_model_overrides model: my_model given: - input: ref('my_model_a') rows: - {id: 1, a: 1} - input: ref('my_model_b') rows: - {id: 1, b: 2} - {id: 2, b: 2} overrides: macros: type_numeric: override invocation_id: 123 vars: my_test: var_override env_vars: MY_TEST: env_var_override expect: rows: - {macro_call: override...

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
testingsqltesting

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 1008-special_case_overrides_8f909542 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 1008 Special Case Overrides 8f909542?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 1008 Special Case Overrides 8f909542
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-1008-special-case-overrides-8f909542/badge)](https://www.skillsdirectory.com/skills/tools-only-1008-special-case-overrides-8f909542)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# Unit test overrides

When configuring your unit test, you can override the output of macros, project variables, or environment variables for a given unit test.

`models/schema.yml`

```yml

 - name: test_my_model_overrides
    model: my_model
    given:
      - input: ref('my_model_a')
        rows:
          - {id: 1, a: 1}
      - input: ref('my_model_b')
        rows:
          - {id: 1, b: 2}
          - {id: 2, b: 2}
    overrides:
      macros:
        type_numeric: override
        invocation_id: 123
      vars:
        my_test: var_override
      env_vars:
        MY_TEST: env_var_override
    expect:
      rows:
        - {macro_call: override, var_call: var_override, env_var_call: env_var_override, invocation_id: 123}

```

## Macros

You can override the output of any macro in your unit test defition. 

If the model you're unit testing uses these macros, you must override them:
  - `is_incremental`: If you're unit testing an incremental model, you must explicity set `is_incremental` to `true` or `false`.

`models/schema.yml`

  ```yml

  unit_tests:
    - name: my_unit_test
      model: my_incremental_model
      overrides:
        macros:
          # unit test this model in "full refresh" mode
          is_incremental: false 
      ...

  ```

  - `dbt_utils.star`: If you're unit testing a model that uses the `star` macro, you must explicity set `star` to a list of columns. This is because the `star` only accepts a relation for the `from` argument; the unit test mock input data is injected directly into the model SQL, replacing the `ref()` or `source()` function, causing the `star` macro to fail unless overidden.

`models/schema.yml`

  ```yml

  unit_tests:
    - name: my_other_unit_test
      model: my_model_that_uses_star
      overrides:
        macros:
          # explicity set star to relevant list of columns
          dbt_utils.star: col_a,col_b,col_c 
      ...

  ``` 

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.