# unable to infer dependencies for custom tests

**URL:** <https://discourse.getdbt.com/t/unable-to-infer-dependencies-for-custom-tests/12443>\
**Category:** Help\
**Tags:** testing, macros\
**Created:** [March 12, 2024, 8:59pm UTC](https://discourse.getdbt.com/t/unable-to-infer-dependencies-for-custom-tests/12443 "2024-03-12T20:59:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamed2](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/iamed2/32/3769_2.png) [@iamed2](https://discourse.getdbt.com/u/iamed2)\
**Post date:** [March 12, 2024, 8:59pm UTC](https://discourse.getdbt.com/t/unable-to-infer-dependencies-for-custom-tests/12443/1 "2024-03-12T20:59:39Z")

</div>

I’m having the exact problem described at [0.19.1 unable to infer dependencies for custom tests · Issue #3229 · dbt-labs/dbt-core · GitHub](https://github.com/dbt-labs/dbt-core/issues/3229), though I’m using this form instead:

```auto
(% test ... %}
{% endtest %}

```

To summarize, I’m trying to have a generic test depend on a model other than the one being tested.

The workaround listed above does work, but adds an unfortunate verbosity to every use of the test.

I have tried adding the `-- depends_on: {{ ref('model_b') }}` (with my ‘model\_b’) at various places in the test file, to no avail.

The GitHub issue claims it was fixed a long time ago; I’m on `1.5.9`. Did that issue only get fixed for macros, and not generic tests?

---

<div class="post-metadata">

**Author:** ![Surya](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/surya/32/3763_2.png) [@Surya](https://discourse.getdbt.com/u/Surya)\
**Post date:** [March 13, 2024, 3:31am UTC](https://discourse.getdbt.com/t/unable-to-infer-dependencies-for-custom-tests/12443/2 "2024-03-13T03:31:46Z")

</div>

`-- {{ ref('model_b') }}`  
can you try like this

---

<div class="post-metadata">

**Author:** ![iamed2](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/iamed2/32/3769_2.png) [@iamed2](https://discourse.getdbt.com/u/iamed2)\
**Post date:** [March 13, 2024, 6:10pm UTC](https://discourse.getdbt.com/t/unable-to-infer-dependencies-for-custom-tests/12443/3 "2024-03-13T18:10:19Z")

</div>

That does work!

I made a reduced and redacted version that could be used for testing; adding or removing the comment determines whether the error appears.

Oh, and I forgot to mention I’m using snowflake plugin, 1.5.1.

```auto
{% test valid_widgets(model, column_name, row_condition, allow_gizmo = True) %}
-- {{ ref('widgets') }}
-- remove the above comment to see the error
    with widgets_filtered as (

        select widget
        from {{ ref('widgets') }}
        {%- if not allow_gizmo %}
        where widget <> 'gizmo'
        {% endif %}

    )

    select {{ column_name }}
    from {{ model }}
    where
        {{ column_name }} is not null
    and
        {{ column_name }} not in (select widget from widgets_filtered)
    {%- if row_condition %}
    and
        {{ row_condition }}
    {% endif %}

{% endtest %}

```

The reference does not appear like it’s in a conditional position, right?
