Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mentioned unit testing example on https://github.com/EqualExperts/dbt-unit-testing not working #187

Open
sushildjoshi opened this issue Nov 24, 2023 · 3 comments
Labels
question Further information is requested

Comments

@sushildjoshi
Copy link

I am resuing below code to do unit testing on my models present in dbt.

I used this package - https://github.com/EqualExperts/dbt-unit-testing/

when I run below mentioned command I can see message " The selection criterion 'tag:unit-tests' does not match any nodes" in system logs and nothing happens.

please help me to figure out what going wrong here

code present in tests.sql inside folder tests/unit
code
command

{{
config(
tags=['unit-test','unit-tests']
)
}}

{% call dbt_unit_testing.test('customers', 'should show customer name') %}

{% call dbt_unit_testing.mock_ref ('stg_customers') %}
select null::Numeric as customer_id, 'John' as first_name, 'Doe' as last_name
{% endcall %}

{% call dbt_unit_testing.mock_ref ('stg_orders') %}
select null::numeric as customer_id, null::numeric as order_id, null as order_date where false
{% endcall %}

{% call dbt_unit_testing.mock_ref ('stg_payments') %}
select null::numeric as order_id, null::numeric as amount where false
{% endcall %}

{% call dbt_unit_testing.expect() %}
select null::Numeric as customer_id, 'John' as first_name, 'Doe' as last_name
{% endcall %}
{% endcall %}

command--

dbt test --select "tag:unit-tests"

@martanthony
Copy link

@sushildjoshi Try removing the quotes around 'tag:unit-tests': dbt test --select tag:unit-tests

@psousa50
Copy link
Collaborator

psousa50 commented Jan 4, 2024

Hi @sushildjoshi , did you manage to solve your issue with @martanthony suggestion?

@psousa50 psousa50 added the question Further information is requested label Jan 4, 2024
@dsmdavid
Copy link

@sushildjoshi I guess this is quite late for you, but maybe useful for anyone in the future looking at this again.
I was having the same issue and realised that there was a typo in the name I had given to the model inside the call statement
{% call dbt_unit_testing.test('dummy', 'testing that I can get unit-test to work') %}
In your case, I don't see the customers model in the tree of files, so maybe it was that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants