Unit tests are not found

The problem I’m having

When trying to run unit tests I get the following error

dbt test --select test_type:unit --debug
...
The selection criterion 'test_type:unit' does not match any enabled nodes
...

The context of why I’m trying to do this

Following the guide here I would like to improve test coverage in the project

What I’ve already tried

Verify I am at 1.8+

dbt --version
Loading .env environment variables...
Core:
  - installed: 1.9.2
...
Plugins:
  - snowflake: 1.9.2
...

dbt test --select "the_model,test_type:unit"
dbt test --select test_type:unit --debug

There doesn’t seem to be any yml parsing errors

yml structure

    unit_tests:
      - name: my_test
        description: Test foobar table
        model: the_model
        overrides:
          macros:
            is_incremental: false
        given:
          - input: ref('the_ref')
            rows:
              - { fake data }
              - { more_data }
        expect:
          rows:
            - { the row}

Im hoping I fat fingered something or am missing something obvious :sweat_smile:

Hi BajaBlaster!

Is the .yml file under /models?

Thank you for the response!

It indeed is.

In this case the file is located at something like: models/base/cloud/team/entity_source/entity/the_model.yml

and follow this structure:

version: 2

models:
  - name: the_model
    meta: ...
    description: ...
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          name: ...
          combination_of_columns:
            - foo
            - bar
            - baz
    unit_tests:
      - name: my_test

EDIT:
I see now that the issue is that the unit tests need to be it’s own file under /models and not in the model definition yml. If there is a best practice for where to put these files that input would be appreciated.

I have a new issue where my team uses a custom 3 argument version of ref but the unit test is expecting a 2 arg version and I am not able to override it.

1 Like