Skip to content

Commit

Permalink
Adding reference page for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewshaver committed Dec 6, 2023
1 parent 5b8666d commit b242461
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
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"
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`
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

0 comments on commit b242461

Please sign in to comment.