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

[Bug] --resource-type test includes both data tests and unit tests #10727

Closed
2 tasks done
dbeatty10 opened this issue Sep 17, 2024 · 0 comments · Fixed by #10718 or #10730
Closed
2 tasks done

[Bug] --resource-type test includes both data tests and unit tests #10727

dbeatty10 opened this issue Sep 17, 2024 · 0 comments · Fixed by #10718 or #10730
Labels
bug Something isn't working dbt tests Issues related to built-in dbt testing functionality node selection Functionality and syntax for selecting DAG nodes unit tests Issues related to built-in dbt unit testing functionality

Comments

@dbeatty10
Copy link
Contributor

dbeatty10 commented Sep 17, 2024

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

✅ This command only includes unit tests:

dbt list --resource-type unit_test

❌ But this one includes both data tests and unit tests:

dbt list --resource-type test

❌ So does this:

dbt build --resource-type test

Expected Behavior

dbt list --resource-type test should only include data tests (and not include unit tests).

Put another way, dbt list --resource-type test and dbt list --resource-type unit_test should have zero overlap in their results.

Likewise, dbt build --resource-type test should only include data tests (and not include unit tests).

Steps To Reproduce

Create these files:

models/hello_world.sql

select 'world' as hello

models/_properties.yml

models:
  - name: hello_world
    columns:
      - name: hello
        tests:
          - not_null

unit_tests:
  - name: test_hello_world
    model: hello_world
    given: []
    expect:
      rows:
        - {hello: world}

Run these commands:

dbt list --resource-type test
dbt list --resource-type unit_test
dbt list --resource-type unit_test test
dbt build --resource-type test

Relevant log output

$ dbt list --resource-type test     
15:21:32  Running with dbt=1.8.6
15:21:35  Registered adapter: postgres=1.8.2
my_project.not_null_hello_world_hello
unit_test:my_project.test_hello_world

$ dbt list --resource-type unit_test     
15:36:53  Running with dbt=1.8.6
15:36:53  Registered adapter: postgres=1.8.2
unit_test:my_project.test_hello_world

$ dbt list --resource-type unit_test test
15:22:07  Running with dbt=1.8.6
15:22:07  Registered adapter: postgres=1.8.2
my_project.not_null_hello_world_hello
unit_test:my_project.test_hello_world

$ dbt build --resource-type test

23:12:47  Running with dbt=1.9.0-a1
23:12:47  Registered adapter: postgres=1.9.0-a1
23:12:48  Found 1 model, 1 test, 422 macros, 1 unit test
23:12:48  
23:12:49  Concurrency: 5 threads (target='postgres')
23:12:49  
23:12:49  1 of 2 START test not_null_hello_world_hello ................................... [RUN]
23:12:49  2 of 2 START unit_test hello_world::test_hello_world ........................... [RUN]
23:12:49  1 of 2 PASS not_null_hello_world_hello ......................................... [PASS in 0.15s]
23:12:49  2 of 2 PASS hello_world::test_hello_world ...................................... [PASS in 0.23s]
23:12:49  
23:12:49  Finished running 1 test, 1 unit test in 0 hours 0 minutes and 1.31 seconds (1.31s).
23:12:49  
23:12:49  Completed successfully
23:12:49  
23:12:49  Done. PASS=2 WARN=0 ERROR=0 SKIP=0 TOTAL=2

Environment

- OS:
- Python:
- dbt: 1.8.6

Which database adapter are you using with dbt?

other (mention it in "Additional Context")

Additional Context

Same thing for all adapters.

@dbeatty10 dbeatty10 added bug Something isn't working triage dbt tests Issues related to built-in dbt testing functionality node selection Functionality and syntax for selecting DAG nodes unit tests Issues related to built-in dbt unit testing functionality and removed triage labels Sep 17, 2024
@dbeatty10 dbeatty10 changed the title [Bug] dbt list test includes both data tests and unit tests [Bug] --resource-type test includes both data tests and unit tests Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dbt tests Issues related to built-in dbt testing functionality node selection Functionality and syntax for selecting DAG nodes unit tests Issues related to built-in dbt unit testing functionality
Projects
None yet
1 participant