Skip to content

[Feature] Disable unit tests whose model is disabled #10540

@SimonCarryer

Description

@SimonCarryer

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

If a model is set to disabled by a macro (for example the standard config macro), then the enabled status is not known at compile time, and unit tests for the model are still compiled. This causes a compilation error:

Compilation Error
  'unit_test.data_staging.my_cool_report.my_cool_unit_test' depends on 'model.data_staging.my_cool_report' which is not in the graph!

Expected Behavior

Usually, if a model is disabled (i.e. enabled: false), then unit tests which test that model are not compiled.

Steps To Reproduce

  1. Create a model which is disabled by a macro (for example {{config(enabled=false)}})
  2. Create a unit test for that model
  3. Run the project

Relevant log output

No response

Environment

- OS: Windows
- Python: 3.12.4
- dbt: 1.8.2

Which database adapter are you using with dbt?

postgres

Additional Context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestpaper_cutA small change that impacts lots of users in their day-to-dayunit testsIssues related to built-in dbt unit testing functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions