Test and Fix
Purpose
This skill provides an autonomous loop to identify, analyze, and fix test failures within the integration_tests directory using the project's make commands.
Loop Logic
- Identify: Run tests from the
integration_testsdirectory.
- Agent must make sure what type of test the user wants to run (unit or integration), becaues it takes a long time to run all tests.
make test: Runs all unit and integration tests (dbt-core and dbt v2). This is the standard command for a full verification.make run-unit-tests: Runs all unit tests (dbt-core and dbt v2).make run-integration-tests: Runs all integration tests (dbt-core and dbt v2).- For targeted debugging, use granular sub-targets:
make run-unit-tests-core/make run-unit-tests-v2make run-integration-tests-core/make run-integration-tests-v2
- Analyze: Examine the test output and logs to understand which tests are failing.
- Check the
logs/dbt.loginintegration_tests/for detailed dbt execution logs. - For macro failures, inspect the generated SQL and compare it with expected BigQuery syntax.
- Note: BigQuery is the only supported warehouse in this repository.
- Plan Fix: Before applying any fix, create an MVP scaffold that delivers the smallest valuable slice of the fix.
- Define acceptance criteria for the fix.
- Create a plan in memory to track the fix progress.
- Execute & Test:
- Implement the MVP scaffold.
- Run the relevant tests immediately (e.g.,
cd integration_tests && make run-unit-tests-core). - Only add details and enhancements after the scaffold tests pass.
- Verify: Re-run the tests.
- If all checks pass: Termination.
- If new or remaining failures exist: Analyze the failure and repeat the loop.
Termination Criteria
- All relevant tests exit with code 0 (all checks passed).
- Reached max iteration limit of 5 attempts.
- No progress being made (same errors persisting despite fix attempts).
Examples
Scenario: Fixing a failing macro unit test
- Agent runs
make testand identifies a failure intest_macrosfor dbt-core. - Agent analyzes the output and finds that
macro_ais returning incorrect SQL for BigQuery. - Agent creates a plan in memory.
- Agent implements a minimal fix for
macro_ato address the specific failure. - Agent runs
make run-unit-tests-coreto quickly verify the fix. - The test passes. Agent runs
make testto ensure no regressions across the entire suite. - The test passes. Agent marks the task as complete.