dbt Analytics Engineering (50 Qs)•Part 3: Enterprise Scale, Performance & CI/CD Pipelines (Senior / Staff)
How does Native Unit Testing work in dbt 1.8+?
senior LevelMost AskedCode ExampleFormsPerformancePipes
In Simple Words: Before dbt 1.8, tests ran only against live database tables. Unit Tests mock static input rows directly in YAML and assert expected output rows without touching production data:
yaml
unit_tests:
- name: test_order_discount_calculation
model: fct_orders
given:
- input: ref('stg_orders')
rows:
- {order_id: 1, base_price: 100, discount_pct: 0.20}
expect:
rows:
- {order_id: 1, final_price: 80.00}