EqualExperts / dbt-unit-testing

This dbt package contains macros to support unit testing that can be (re)used across dbt projects.
MIT License
421 stars 78 forks source link

Test only runs with `dbt build`, `dbt test` leads to "Nothing to do" #206

Closed barberadam closed 7 months ago

barberadam commented 8 months ago

I'm trying to test out this library as a unit testing solution for our project. My test is set up like so (redacting some names):

{{ config(tags=['unit-test']) }}
{% set options = {"include_missing_columns": true} %}

{% call dbt_unit_testing.test('<model_name>', 'test_description_here') %}
  {% call dbt_unit_testing.mock_source('<source>', '<source table name>', options) %}
     select ...
  {% endcall %}
  ...
  {% call dbt_unit_testing.expect() %}
    select ...
  {% endcall %}
{% endcall %}

This model uses no refs, its all sources, I've replaced those source macros with dbt_unit_testing.source. Note I did also set the use_qualified_sources parameter in my dbt_project.yml.

If I attempt to run with dbt test -s tag:unit-test I get:

16:38:13  Running with dbt=1.6.0
16:38:13  Registered adapter: snowflake=1.6.0
16:38:13  Unable to do partial parsing because config vars, config profile, or config target have changed
16:38:26  Found 963 models, 20 snapshots, 5 analyses, 30 seeds, 714 tests, 1472 sources, 0 exposures, 0 metrics, 854 macros, 0 groups, 0 semantic models
16:38:26  
16:38:26  Nothing to do. Try checking your model configs and model specification args

If I run dbt build -s tag:unit-test the test actually runs, so I know the config is mostly right.

I'm guessing I have some incompatible config but not sure where to start looking.

I'm on 1.6.0 for dbt and using latest release (v0.4.12) of this package.

psousa50 commented 7 months ago

Hi @barberadam,

could you please check the config value for test-paths in your dbt_project.ym? Are you sure that your test file is in the folder specified there?

barberadam commented 7 months ago

@psousa50 Yup that was it! I figured it was something silly like that but couldn't find it -- might be nice to add it to the docs but it doesn't look like others have missed that step.

Thanks!

psousa50 commented 7 months ago

No worries 🙂 . This is a dbt configuration, not a dbt-unit-testing configuration, so it's in the dbt docs.