Metadata
- Author: Pablo Porto
- Full Title:: How to Improve the Code Quality of Your DBT Models With Unit Tests and TDD
- Category:: 🗞️Articles
- Document Tags:: dbt,
- URL:: https://towardsdatascience.com/improving-the-code-quality-of-your-dbt-models-with-unit-tests-and-tdd-203ed0be791e
- Finished date:: 2023-07-08
Highlights
The building blocks Looking at the previous test, we can see several of the dbt-unit-testing macros in use: • dbt_unit_testing.test: This macro allows us define the model under test and the name of the test. In our example we reference to int_weight_measurements_with_latest_height. • dbt_unit_testing.mock_ref: This macro allows us to mock references to other dbt models. In our example, we are mocking the weight (stg_gym_app__weight) and the height (stg_gym_app__height) staging data. • dbt_unit_testing.expect: And this macro allows us to assert on the result of the transformation. In the example, we assert that the weight measurement gets enriched with the latest height. (View Highlight)