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

[Feature] Allow for real data in unit tests #11130

Open
3 tasks done
mvgijssel opened this issue Dec 11, 2024 · 0 comments
Open
3 tasks done

[Feature] Allow for real data in unit tests #11130

mvgijssel opened this issue Dec 11, 2024 · 0 comments
Labels
enhancement New feature or request triage

Comments

@mvgijssel
Copy link

mvgijssel commented Dec 11, 2024

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

I work for a company called HackerOne and we have a use case for running unit tests without mocking the inputs. There are a couple of models which are fairly complicated which we currently test with a singular data test. The test basically does the following using SQL:

  • Does the table contain a row with properties "title: foo, state: 2, amount: 99"
  • Does the table contain a row with properties "title: bar, state: 9, amount: 50"
  • ...

Because this test passes if there are 0 rows, we have to write the tests in an inverse manner which is hard to understand and debug. When it fails it's unclear why exactly.

So something like the following would be amazing

unit_tests:
  - name: the_test
    model: complicated_model # name of the model I'm unit testing
    given: # the mock data for your inputs
      - input: ref('accounts') # use a regular dbt model
      - input: ref('users') # use a regular dbt model
    expect: 
      rows:
        - { title: foo, state: 2, amount: 99 }
        - { title: bar, state: 9, amount: 50 }

Describe alternatives you've considered

Singular data test, which is not very developer friendly

Who will this benefit?

I think this would be beneficial for folks with complicated models that want to do "row" based testing.

Are you interested in contributing this feature?

If possible, sure why not!

Anything else?

No response

@mvgijssel mvgijssel added enhancement New feature or request triage labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage
Projects
None yet
Development

No branches or pull requests

1 participant