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

Fast follows for Unit Testing #4889

Closed
1 task
matthewshaver opened this issue Feb 10, 2024 · 15 comments · Fixed by #4975
Closed
1 task

Fast follows for Unit Testing #4889

matthewshaver opened this issue Feb 10, 2024 · 15 comments · Fixed by #4975
Assignees
Labels
content Improvements or additions to content dbt-core v1.8 improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@matthewshaver
Copy link
Contributor

Contributions

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

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

https://docs.getdbt.com/reference/node-selection/methods#the-test_type-method

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

can we update this page too with the new test_types

Additional information

No response

@matthewshaver matthewshaver added content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear labels Feb 10, 2024
@matthewshaver matthewshaver self-assigned this Feb 10, 2024
@matthewshaver
Copy link
Contributor Author

Add format types

Add best practices for when to run unit tests

@matthewshaver
Copy link
Contributor Author

Add format section to explain dict and csv data formats

@matthewshaver
Copy link
Contributor Author

One more section here on "When to run your unit tests"

Like the general best practice on "run your unit tests in dev / ci" but not in prod - and maybe some thoughts/best practices around warehouse sizing?

@graciegoheen
Copy link
Collaborator

Oooh can we update this page too with the new test_types -> https://docs.getdbt.com/reference/node-selection/methods#the-test_type-method

@graciegoheen
Copy link
Collaborator

graciegoheen commented Feb 14, 2024

dbt build (how unit tests fit into the dbt build command)

docs for dbt build with unit tests

@graciegoheen
Copy link
Collaborator

Likely out of scope of this PR, but do we have an open issue already for documenting data_tests:?

For for backward compatibility tests: will be an alias for data_tests: in yml configuration files, but we will eventually deprecate tests:

models:
  - name: orders
    columns:
      - name: order_id
        data_tests:
          - unique
          - not_null
# dbt_project.yml

data_tests: # legacy tests:

@graciegoheen
Copy link
Collaborator

Link to docs for --empty flag

@matthewshaver
Copy link
Contributor Author

We need to update the dbt build command page as well

@graciegoheen
Copy link
Collaborator

Really love how you nested data tests and unit tests under a "tests" section - I wonder if it would be valuable to have an "About dbt tests" page (similar to the "About dbt models") to talk more broadly about what "tests" are and how they're used. Could reduce some of the duplication of docs between data / unit (like the dbt test command).

We could also put some of the "this is how data tests and unit tests relate to each other" type of info on that page.

Maybe out-of-scope for this initial pass, but just a thought!

@graciegoheen
Copy link
Collaborator

I like how for the data tests ref section we have mini pages for the configs you can use for your data tests:
Screenshot 2024-02-12 at 11 21 51 AM

Could we do the same for unit tests? I think we could break up the "about writing unit tests" section into separate pages on format, expect, given, overrides, etc.

@graciegoheen
Copy link
Collaborator

Nit-pick:
the actual logs have some specific formatting (color + bolding) to make this error message clearer to read - would it be possible to include that formatting here?

Screenshot 2024-02-14 at 10 30 45 AM
  • "Fail 1" is red
  • "Complete with 1 error and 0 warnings:" is red
  • "Failure in unit_test test_is_valid_email_address (models/marts/unit_tests.yml)" is red
  • "actual" is green
  • "expected" is red
  • "True" is red and bold
  • "False" is green and bold

@graciegoheen
Copy link
Collaborator

Same nit-pick as above:
Screenshot 2024-02-14 at 10 31 48 AM

  • "PASS" is green
  • "Completed successfully" is green

@graciegoheen
Copy link
Collaborator

graciegoheen commented Feb 20, 2024

Screenshot 2024-02-20 at 4 25 48 PM

add overrides examples for vars, macros, and env_vars https://github.com/dbt-labs/dbt-core/blob/7df747ae04a8c99dbd745085f42cd4647ec71d80/tests/functional/unit_testing/fixtures.py#L82

@graciegoheen
Copy link
Collaborator

graciegoheen commented Feb 22, 2024

IMPORTANT -> We should make it clear that unit tests must be defined in a YML file in your models/ directory in the unit testing docs

graciegoheen added a commit that referenced this issue Feb 23, 2024
## What are you changing in this pull request and why?
<!---
Describe your changes and why you're making them. If related to an open 
issue or a pull request on dbt Core, then link to them here! 

To learn more about the writing conventions used in the dbt Labs docs,
see the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md).
-->

Add more docs / examples to overrides for unit testing - fast follow
from here #4889

## Checklist
<!--
Uncomment when publishing docs for a prerelease version of dbt:
- [ ] Add versioning components, as described in [Versioning
Docs](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-entire-pages)
- [ ] Add a note to the prerelease version [Migration
Guide](https://github.com/dbt-labs/docs.getdbt.com/tree/current/website/docs/docs/dbt-versions/core-upgrade)
-->
- [ ] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.
- [ ] For [docs
versioning](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#about-versioning),
review how to [version a whole
page](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version)
and [version a block of
content](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-blocks-of-content).
- [ ] Add a checklist item for anything that needs to happen before this
PR is merged, such as "needs technical review" or "change base branch."

Adding or removing pages (delete if not applicable):
- [ ] Add/remove page in `website/sidebars.js`
- [ ] Provide a unique filename for new pages
- [ ] Add an entry for deleted pages in `website/static/_redirects`
- [ ] Run link testing locally with `npm run build` to update the links
that point to deleted pages
@matthewshaver matthewshaver linked a pull request Feb 26, 2024 that will close this issue
3 tasks
@matthewshaver
Copy link
Contributor Author

Likely out of scope of this PR, but do we have an open issue already for documenting data_tests:?

For for backward compatibility tests: will be an alias for data_tests: in yml configuration files, but we will eventually deprecate tests:

models:
  - name: orders
    columns:
      - name: order_id
        data_tests:
          - unique
          - not_null
# dbt_project.yml

data_tests: # legacy tests:

Created this issue and will follow up!

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 dbt-core v1.8 improvement Use this when an area of the docs needs improvement as it's currently unclear
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants