This project illustrates the usage of dbt-unit-testing in dbt's fictional ecommerce store.
This repo contains the original jaffle_shop project structure plus unit tests.
The project is composed by seeds to simulate data from three entities Customers, Orders and Payments, with the following entity-relationship diagram:
Using the described seeds, there's a staging layer composed by one model per each seed, and the final model is a customers model with the following calculated fields: first_order, most_recent_order and number_of_orders.
(Orders model was removed from the original jaffle_shop for simplicity)
To illustrate how you can do unit testing using the dbt-unit-testing framework, there is a test suite that you can inspect. We've created 3 different files that corresponds to the same test suite, but with different mocking strategies. If you're not familiar with mocking strategies please check the (../README.md).
- Tests using full mocking strategy
- Tests using simplified mocking strategy
- Tests using pure mocking strategy
Inside each test file there are exatly the same tests so you can compare the pure strategy (simplest) with more helpfull strategies Full/Simplified.
Note: when using Full/Simplified mocking strategies, they're relying in documentation of seeds and models, not in database dependencies.
If you want to run the tests on your machine and play with the examples:
- You need to have docker.
- Clone this repository.
- Use make to run
make