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

Add more context to unit tests and best practices #5311

Open
1 task done
mirnawong1 opened this issue Apr 19, 2024 · 0 comments
Open
1 task done

Add more context to unit tests and best practices #5311

mirnawong1 opened this issue Apr 19, 2024 · 0 comments
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@mirnawong1
Copy link
Contributor

mirnawong1 commented Apr 19, 2024

Contributions

  • I have read the contribution docs, and understand what's expected of me.

Link to the page on docs.getdbt.com requiring updates

Per slack convo, the following unit test best practices/recommendations from @graciegoheen would be beneficial to add to the docs so users understand what works best for them:

Inline vs. fixtures

  • inline is better when you have a small number of edge cases, and you want to be able to see that data in your yml file that defines your unit test
    • i think it’s easier to troubleshoot a unit test when everything is in the same file
  • fixtures are better when you have lots of edge cases, so if you put it all in one yml file the file would be GIANT
    • i also think fixures are better for the sql format
    • but then you have to jump around between the fixture file and the yml file

dict vs. csv vs. sql

  • dict is the default, it’s always inline so contains your data in the yml file for easy viewing
  • csv is what a lot of folks are used to if they’ve been using a unit testing package (via seeds) - so this is recommended for folks that are migrating from unit testing package, or who have less technical folks that prefer looking at csv
  • sql is for expanding the type of data you can unit test
    • can unit test more data types (think structs, geography, etc.)
    • total control over the sql
    • can unit test models that depend on ephemeral models
    • BUT when using this format you must define mock data for all columns

What part(s) of the page would you like to see updated?

https://docs.getdbt.com/docs/build/unit-tests

Additional information

No response

@mirnawong1 mirnawong1 added content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear
Projects
None yet
Development

No branches or pull requests

1 participant