0
0
dbtdata~10 mins

Running tests with dbt test - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Running tests with dbt test
Write tests in schema.yml
Run 'dbt test' command
dbt executes tests on data
Tests pass?
NoShow errors and failing rows
Yes
All tests pass
End
You write tests in your dbt project, run 'dbt test', and dbt checks your data, showing results or errors.
Execution Sample
dbt
dbt test
-- runs all tests defined in schema.yml
-- checks data quality and constraints
This command runs all tests defined in your dbt project to validate your data.
Execution Table
StepActionTest TypeTest TargetResultOutput
1Start dbt testN/AN/ARunningStarting tests...
2Run unique testuniquecolumn: user_idPassNo duplicates found
3Run not_null testnot_nullcolumn: emailFailFound 3 null values
4Run accepted_values testaccepted_valuescolumn: statusPassAll values valid
5SummaryN/AN/AFail1 test failed: not_null on email
6EndN/AN/AStoppedFix errors and rerun
💡 Test run ends because one or more tests failed, showing errors for correction.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
Tests Run01233
Tests Passed01122
Tests Failed00111
Error Messages[][]["Found 3 null values in email"]["Found 3 null values in email"]["Found 3 null values in email"]
Key Moments - 2 Insights
Why does dbt stop the test run after a failure?
dbt runs all tests but reports failures at the end; the process shows all results but highlights failures for you to fix, as seen in step 5 of the execution_table.
What does a 'not_null' test check?
It checks that no values in the specified column are null. In the execution_table step 3, the test failed because 3 null values were found in the email column.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, what was the test result for the 'not_null' test on 'email'?
AFail
BSkipped
CPass
DRunning
💡 Hint
Check the 'Result' column in row 3 of the execution_table.
At which step does dbt report the summary of all tests?
AStep 2
BStep 3
CStep 5
DStep 6
💡 Hint
Look for the row with 'Summary' in the 'Action' column in the execution_table.
If the 'not_null' test on 'email' passed, how would the 'Tests Failed' variable change after step 3?
AIt would increase by 1
BIt would remain 0
CIt would remain 1
DIt would decrease by 1
💡 Hint
Check the variable_tracker for 'Tests Failed' after step 3 and imagine no failures occurred.
Concept Snapshot
dbt test runs data quality checks defined in schema.yml
Common tests: unique, not_null, accepted_values
Run with 'dbt test' command
Reports pass/fail for each test
Fix failures and rerun tests
Full Transcript
Running tests with dbt test involves writing tests in your dbt project files, then executing the 'dbt test' command. This command runs all defined tests such as uniqueness, not-null constraints, and accepted values on your data. The process outputs results step-by-step, showing which tests pass or fail. If any test fails, dbt reports the errors so you can fix them. After fixing, you rerun the tests to ensure data quality. This visual trace shows the flow from starting tests, running each test, reporting results, and ending with a summary.