From 364da5b74346d27fe7edbaac140e22f290be51cf Mon Sep 17 00:00:00 2001 From: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> Date: Tue, 1 Oct 2024 09:39:18 -0600 Subject: [PATCH] `dbt test` supports `--resource-type` / `--exclude-resource-type` CLI flags and related environment variables (#6192) [Preview](https://docs-getdbt-com-git-dbeatty-6101-docs-dbt-labs.vercel.app/reference/global-configs/resource-type) Resolves https://github.com/dbt-labs/docs.getdbt.com/issues/6101 Originally https://github.com/dbt-labs/docs.getdbt.com/pull/6126 ## What are you changing in this pull request and why? Beginning in dbt-core v1.9, it is possible to use the `--resource-type` and `--exclude-resource-type` CLI flags (and related env vars) with the `dbt test` command. ## Checklist - [x] I have reviewed the [Content style guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md) so my content adheres to these guidelines. - [x] The topic I'm writing about is for specific dbt version(s) and I have versioned it according to the [version a whole page](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version) and/or [version a block of content](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-blocks-of-content) guidelines. - [x] Add a note to the prerelease version [Migration Guide](https://github.com/dbt-labs/docs.getdbt.com/tree/current/website/docs/docs/dbt-versions/core-upgrade) --------- Co-authored-by: Natalie Fiann Co-authored-by: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Co-authored-by: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> --- .../reference/global-configs/resource-type.md | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/website/docs/reference/global-configs/resource-type.md b/website/docs/reference/global-configs/resource-type.md index ad8897a745c..9e6ec82df06 100644 --- a/website/docs/reference/global-configs/resource-type.md +++ b/website/docs/reference/global-configs/resource-type.md @@ -4,7 +4,17 @@ id: "resource-type" sidebar: "resource type" --- -The `--resource-type` and `--exclude-resource-type` flags include or exclude resource types from the `dbt build`, `dbt clone`, and `dbt list` commands. + + +The `--resource-type` and `--exclude-resource-type` flags include or exclude resource types from the `dbt build`, `dbt clone`, and `dbt list` commands. In Versionless and from dbt v1.9 onwards, these flags are also supported in the `dbt test` command. + + + + + +The `--resource-type` and `--exclude-resource-type` flags include or exclude resource types from the `dbt build`, `dbt test`, `dbt clone`, and `dbt list` commands. + + This means the flags enable you to specify which types of resources to include or exclude when running the commands, instead of targeting specific resources. @@ -109,3 +119,27 @@ Instead of targeting specific resources, use the `--resource-flag` or `--exclude + + + +- In this example, use the following command to exclude _all_ unit tests when running tests: + + + + ```text + dbt test --exclude-resource-type unit_test + ``` + + + +- In this example, use the following command to include all data tests when running tests: + + + + ```text + dbt test --resource-type test + ``` + + + +