# Singular test - How to skip testing all models inside a JOIN ?

**URL:** <https://discourse.getdbt.com/t/singular-test-how-to-skip-testing-all-models-inside-a-join/14500>\
**Category:** Help\
**Tags:** testing, dbt-core\
**Created:** [July 24, 2024, 7:37pm UTC](https://discourse.getdbt.com/t/singular-test-how-to-skip-testing-all-models-inside-a-join/14500 "2024-07-24T19:37:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmarcelo](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mmarcelo](https://discourse.getdbt.com/u/mmarcelo)\
**Post date:** [July 24, 2024, 7:37pm UTC](https://discourse.getdbt.com/t/singular-test-how-to-skip-testing-all-models-inside-a-join/14500/1 "2024-07-24T19:37:21Z")

</div>

Hi there

I have two models and I need to test whether all lines from one model were rolled up to a second model.

Testing is very easy as I only need to create a singular test and write a LEFT OUTER JOIN between these 2 models, but when I run “dbt test --select s4\_venda\_mensal”, dbt run the singular test which fails because lines from “s4\_venda\_mensal” (model one) were not moved to “s4\_ocupacao” (model two).

In my case, the singular test is only relevant to test “s4\_ocupacao” (model two), but dbt understands that all models referred in singular test should be tested when “dbt test” is invoked for individual model.

Question: how to skip testing a given singular test from a given model?

That’s my singular test script:

```auto
SELECT
    vnd.nr_competencia,
    vnd.pk_contrato,
    vnd.vl_venda
FROM {{ ref('s4_venda_mensal') }} AS vnd
LEFT OUTER JOIN {{ ref('s4_ocupacao') }} AS ocu
    ON ocu.nr_competencia = vnd.nr_competencia
    AND ocu.pk_contrato = vnd.pk_contrato
WHERE vnd.nr_competencia IN (SELECT nr_competencia FROM var_periodo)
  AND ocu.pk_contrato IS NULL

```

As said, this script is only relevant to test model name s4\_ocupacao. When I run “dbt test --select sr\_venda\_mensal” it would be nice if the singular test would be skipped.

Any thoughts ?

---

<div class="post-metadata">

**Author:** ![a\_slack\_user](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/a_slack_user/32/1629_2.png) [@a\_slack\_user](https://discourse.getdbt.com/u/a_slack_user)\
**Post date:** [July 24, 2024, 7:50pm UTC](https://discourse.getdbt.com/t/singular-test-how-to-skip-testing-all-models-inside-a-join/14500/2 "2024-07-24T19:50:28Z")

</div>

You might be looking for `--indirect-selection=cautious`  
Details here: [https://docs.getdbt.com/reference/node-selection/test-selection-examples?indirect-selection-mode=eager#indirect-selection](https://docs.getdbt.com/reference/node-selection/test-selection-examples?indirect-selection-mode=eager#indirect-selection)

Note: `@Owen` originally [posted this reply in Slack](https://getdbt.slack.com/archives/CBSQTAPLG/p1721850620457739?thread_ts=1721849865.882339&cid=CBSQTAPLG). It might not have transferred perfectly.

---

<div class="post-metadata">

**Author:** ![mmarcelo](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mmarcelo](https://discourse.getdbt.com/u/mmarcelo)\
**Post date:** [July 24, 2024, 9:28pm UTC](https://discourse.getdbt.com/t/singular-test-how-to-skip-testing-all-models-inside-a-join/14500/3 "2024-07-24T21:28:14Z")

</div>

Interesting documentation. Thanks for sharing.

Well, it only works when adding to selectors. Is there another way to make it valid for all selectors?

It would be nice to set on config section of singular test, but it think it’s not possible.

Maybe, concatenating enrironment variables to get schema name with table name (constant string). It will bypass ref function, but it’s an ugly solution.
