-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding reference page for unit tests
- Loading branch information
1 parent
5b8666d
commit b242461
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: "About unit tests property" | ||
sidebar_label: "unit tests" | ||
resource_types: [models] | ||
datatype: test | ||
--- | ||
|
||
<file name='dbt_project.yml'> | ||
|
||
```yml | ||
unit-tests: | ||
- name: <test-name> # this is the unique name of the test | ||
model: <model-name> | ||
config: | ||
meta: {dictionary} | ||
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 | ||
|
||
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. | ||
|
||
To run just your unit tests: | ||
`dbt test —-select test_type:unit` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters