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

Adding Unit testing docs and reference page #4603

Merged
merged 94 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
61fdb9c
Adding multi cell
matthewshaver Dec 1, 2023
2e1aa1a
Updating links to access
matthewshaver Dec 1, 2023
b242461
Adding reference page for unit tests
matthewshaver Dec 6, 2023
840eed4
Unit tests
matthewshaver Dec 6, 2023
3dd2aad
Merge branch 'current' into next
matthewshaver Dec 11, 2023
6ce45ff
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Jan 9, 2024
47d2827
Merge branch 'next' into unit-testing
matthewshaver Jan 9, 2024
214eb6f
Update website/dbt-versions.js
matthewshaver Jan 9, 2024
12fbe42
Fixing spacing changes
matthewshaver Jan 9, 2024
8eee934
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Jan 10, 2024
a790962
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Jan 10, 2024
b6d8ed6
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Feb 7, 2024
9772609
Adding /docs page for unit tests
matthewshaver Feb 7, 2024
19fd463
fixing spacing on YML
matthewshaver Feb 7, 2024
f044ff1
Update unit-tests.md
matthewshaver Feb 7, 2024
56db5ca
Update unit-tests.md
matthewshaver Feb 7, 2024
6112e01
Update unit-tests.md
matthewshaver Feb 7, 2024
1687dd3
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 9, 2024
a18b387
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 9, 2024
5ffa00b
Updates
matthewshaver Feb 9, 2024
2329f3f
Updates from feedback
matthewshaver Feb 9, 2024
02e057b
Updates
matthewshaver Feb 9, 2024
d1e46f0
Merge branch 'current' into unit-testing
matthewshaver Feb 9, 2024
829c40c
Reverting changes
matthewshaver Feb 9, 2024
7547ecb
fixing edits
matthewshaver Feb 9, 2024
ada5919
fixing
matthewshaver Feb 9, 2024
59cbb84
fixing
matthewshaver Feb 9, 2024
4fb38a2
Updating sidebar folders
matthewshaver Feb 9, 2024
6fe72ff
Fixing errors
matthewshaver Feb 9, 2024
d621b2b
Update unit-tests.md
matthewshaver Feb 9, 2024
b6376c1
fixing yet another merge error
matthewshaver Feb 9, 2024
b0a3ba7
Merge branch 'unit-testing' of https://github.com/dbt-labs/docs.getdb…
matthewshaver Feb 9, 2024
688aede
Update unit-tests.md
matthewshaver Feb 9, 2024
80ec818
Update unit-tests.md
matthewshaver Feb 9, 2024
ed9e312
Updating based on feedback
matthewshaver Feb 9, 2024
0cf9022
Merge branch 'unit-testing' of https://github.com/dbt-labs/docs.getdb…
matthewshaver Feb 9, 2024
420e2f1
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 9, 2024
75ca6f5
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 9, 2024
4281976
Update unit-tests.md
matthewshaver Feb 9, 2024
9dbb79a
Update unit-tests.md
matthewshaver Feb 9, 2024
0de14e7
Apply suggestions from code review
dbeatty10 Feb 10, 2024
b94fb0a
Apply suggestions from code review
matthewshaver Feb 10, 2024
353c4f3
Update unit-tests.md
matthewshaver Feb 10, 2024
5bfff10
updating spacing
matthewshaver Feb 10, 2024
37df470
Update website/docs/reference/resource-properties/unit-tests.md
runleonarun Feb 10, 2024
39b83aa
Update website/docs/reference/commands/test.md
matthewshaver Feb 10, 2024
90526f6
Update website/docs/reference/resource-properties/unit-tests.md
runleonarun Feb 10, 2024
e213f47
Merge branch 'current' into unit-testing
runleonarun Feb 10, 2024
ab28f99
Apply suggestions from code review
matthewshaver Feb 10, 2024
f5753a7
Update website/docs/docs/build/unit-tests.md
runleonarun Feb 10, 2024
3872aaa
Update website/docs/docs/build/unit-tests.md
runleonarun Feb 10, 2024
567ef15
Update website/docs/docs/build/unit-tests.md
runleonarun Feb 10, 2024
57cbfe1
Update unit-tests.md
matthewshaver Feb 10, 2024
1a7d70d
Apply suggestions from code review
matthewshaver Feb 10, 2024
0d6b78a
Update unit-tests.md
matthewshaver Feb 10, 2024
5c50489
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 13, 2024
92b55c0
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Feb 13, 2024
810180d
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 13, 2024
225f48f
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Feb 13, 2024
ea79e05
Update unit-tests.md
matthewshaver Feb 13, 2024
fc0ba3a
Update unit-tests.md
matthewshaver Feb 13, 2024
fb45528
Update unit-tests.md
matthewshaver Feb 13, 2024
c0aa1d2
Merge branch 'current' into unit-testing
matthewshaver Feb 13, 2024
2edec42
Update website/sidebars.js
matthewshaver Feb 13, 2024
158ea89
Update unit-tests.md
matthewshaver Feb 13, 2024
8b4b31b
Update unit-tests.md
matthewshaver Feb 13, 2024
0a91b5e
Merge branch 'current' into unit-testing
runleonarun Feb 13, 2024
27ecde3
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
fba1903
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
bdfc000
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
58c41a6
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
f67b779
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
db435da
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
97f7e7a
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
62ce8c6
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
8bd64f7
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
72b84f2
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
dbd0aa4
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
12f92a8
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
dd87c90
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
694037a
Update unit-tests.md
matthewshaver Feb 14, 2024
528e653
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
5870f96
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Feb 14, 2024
c10ea49
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Feb 14, 2024
95cd74b
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Feb 14, 2024
7b3f23b
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Feb 14, 2024
ef9ceee
Update website/docs/reference/resource-properties/unit-tests.md
matthewshaver Feb 14, 2024
d6b4fa1
Apply suggestions from code review
matthewshaver Feb 14, 2024
8503acd
Apply suggestions from code review
matthewshaver Feb 14, 2024
a1b3614
Update website/docs/docs/build/unit-tests.md
matthewshaver Feb 14, 2024
ba74fe5
Apply suggestions from code review
graciegoheen Feb 14, 2024
9c626b9
Fixing format and spacing
matthewshaver Feb 14, 2024
6b8e034
fixing links
matthewshaver Feb 14, 2024
11fc966
Merge branch 'current' into unit-testing
matthewshaver Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions website/dbt-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ exports.versions = [
]

exports.versionedPages = [
{
"page": "reference/resource-properties/unit-tests",
"firstVersion": "1.7",
matthewshaver marked this conversation as resolved.
Show resolved Hide resolved
matthewshaver marked this conversation as resolved.
Show resolved Hide resolved
},
{
"page": "reference/resource-configs/store_failures_as",
"firstVersion": "1.7",
Expand Down
51 changes: 51 additions & 0 deletions website/docs/reference/resource-properties/unit-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "About unit tests property"
graciegoheen marked this conversation as resolved.
Show resolved Hide resolved
sidebar_label: "unit tests"
resource_types: [models]
datatype: test
---

graciegoheen marked this conversation as resolved.
Show resolved Hide resolved
<file name='dbt_project.yml'>

```yml
unit-tests:
matthewshaver marked this conversation as resolved.
Show resolved Hide resolved
- name: <test-name> # this is the unique name of the test
model: <model-name>
config:
meta: {dictionary}
matthewshaver marked this conversation as resolved.
Show resolved Hide resolved
tags: <string> | [<string>]
given:
- input: <ref_or_source_call> # optional for seeds
format: dict | csv
# if format csv, either define dictionary of rows or name of fixture
rows:
- {dictionary}
fixture: <fixture-name>
- input: ... # declare additional inputs
expect:
format: dict | csv
# if format csv, either define dictionary of rows or name of fixture
rows:
- {dictionary}
fixture: <fixture-name>
overrides: # optional: configuration for the dbt execution environment
macros:
is_incremental: true | false
dbt_utils.current_timestamp: str
# ... any other jinja function from https://docs.getdbt.com/reference/dbt-jinja-functions
# ... any other context property
vars: {dictionary}
env_vars: {dictionary}
- name: <test-name> ... # declare additional unit tests

```

</file>


## Definition
matthewshaver marked this conversation as resolved.
Show resolved Hide resolved

Unit tests validate your modeling logic on a small set of static inputs before you materialize your full model in production. Unit tests enable test-driven development, with benefits for developer efficiency and code reliability.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving the definition to the top so people can see it in google searches

matthewshaver marked this conversation as resolved.
Show resolved Hide resolved

To run just your unit tests:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To run just your unit tests:
To execute only your unit tests, use the command:

matthewshaver marked this conversation as resolved.
Show resolved Hide resolved
`dbt test —-select test_type:unit`
matthewshaver marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ const sidebarSettings = {
"reference/resource-properties/include-exclude",
"reference/resource-properties/quote",
"reference/resource-properties/tests",
"reference/resource-properties/unit-tests",
"reference/resource-properties/versions",
],
},
Expand Down
Loading