This skill systematizes test execution, failure analysis, debugging, and test suite health monitoring. It acts as a QA specialist who ensures tests run methodically, failures are debugged with structure, fixes are validated thoroughly, and the test suite remains healthy and maintainable.
Core philosophy: Testing is a discipline, not an afterthought. Every test execution should be strategic, every failure debugged systematically, and every fix validated against regression. Quality metrics should improve steadily over time.
When to Use This Skill
Trigger phrases:
Test Execution:
"Run all tests"
"Execute test suite"
"Run tests for [component]"
"Test the changes"
"Verify tests pass"
"Pre-merge test check"
Debugging:
"Debug test failure in [test]"
"Fix failing test [name]"
"Why is [test] failing?"
"Investigate test failures"
"Tests are broken"
Health Monitoring:
"Check test suite health"
"Analyze test coverage"
"Find flaky tests"
"Review test metrics"
"Test suite status"
Use cases:
Systematic Execution - Run tests at the right level for the current context
Failure Debugging - Methodically investigate and fix test failures
Health Monitoring - Track coverage, flakiness, and suite quality
Test Execution Plan
CHECKPOINT 1: Test Selection
───────────────────────────────────────
Context: [What changed and why tests are needed]
Changes Detected:
- [file 1] ([type of change])
- [file 2] ([type of change])
Affected Components:
- [component 1]
- [component 2]
Recommended Test Level: [1/2/3/4] - [Level Name]
Tests to Run:
- [test category 1]: [specific test files or directories]
- [test category 2]: [specific test files or directories]
Estimated Duration: [X minutes]
Proceed with this test plan? (y/n/adjust)
Wait for user response before proceeding.
Checkpoint 2: Pre-Execution Checks
Purpose: Ensure the test environment is ready.
Actions:
Run flutter analyze for static analysis
Verify no compilation errors
Check test file existence
Verify mock infrastructure
Output format:
───────────────────────────────────────
CHECKPOINT 2: Pre-Execution Checks
Running pre-flight checks...
Static Analysis:
- flutter analyze: [X issues / No issues] [✓/✗]
Compilation:
- Test files compile: [Yes/No] [✓/✗]
Test Infrastructure:
- MockDatabaseHelper available: [Yes/No] [✓/✗]
- Test helpers available: [Yes/No] [✓/✗]
- Test fixtures accessible: [Yes/No] [✓/✗]
Environment:
- Flutter version: [version]
- Platform: [platform]
Pre-flight Status: [✓ READY / ✗ BLOCKED]
[If BLOCKED: Show specific issues and remediation steps]
Ready to execute? (y/n/fix issues)
Wait for user response before proceeding.
Checkpoint 3: Test Execution
Purpose: Run the tests and collect results.
Actions:
Execute the selected test command(s)
Capture pass/fail/skip counts
Capture duration
List all failures with details
Output format:
───────────────────────────────────────
CHECKPOINT 3: Test Execution
Executing: flutter test [args]
Results:
Passed: [X] tests
Failed: [Y] tests
Skipped: [Z] tests
Duration: [Xm Ys]
[If all passed:]
All tests passed! ✓
No failures to analyze.
Proceed to commit/merge? (y/n)
[If failures exist:]
Failed Tests:
1. [test_file.dart]:[line]
Test: "[test name]"
Error: [error message]
2. [test_file.dart]:[line]
Test: "[test name]"
Error: [error message]
[... list all failures ...]
Analyze failures? (y/n/re-run)
Wait for user response before proceeding.
Checkpoint 4: Results Analysis
Purpose: Categorize failures and determine next steps.
Actions:
Categorize each failure by severity
Identify failure patterns
Check for flaky test indicators
Recommend prioritized actions
Output format:
───────────────────────────────────────
CHECKPOINT 4: Results Analysis
Failure Analysis:
CRITICAL (blocks merge):
- [test]: [reason - e.g., null safety violation, data corruption]
IMPORTANT (should fix):
- [test]: [reason - e.g., expectation mismatch, logic error]
INVESTIGATE (may be flaky):
- [test]: [reason - e.g., timeout, intermittent failure]
Pattern Detection:
- [Pattern found, e.g., "All 3 failures in meal_service - likely same root cause"]
- [Pattern found, e.g., "Timeout in dialog test - possible flaky test"]
Recommended Action Plan:
1. [First action - fix critical failure]
2. [Second action - investigate pattern]
3. [Third action - check flaky test]
Proceed with debugging? (y/n/re-run specific tests)
Wait for user response before proceeding.
Process B: Structured Debugging (5 Checkpoints)
Use when: A test failure needs investigation and fixing.
Checkpoint Flow Overview
Trigger: "Debug failing test" / Failure from test execution
|
Checkpoint 1: Failure Understanding (WAIT)
|
Checkpoint 2: Root Cause Hypothesis (WAIT)
|
Checkpoint 3: Investigation (WAIT)
|
Checkpoint 4: Fix Implementation (WAIT)
|
Checkpoint 5: Fix Validation (WAIT)
|
Test Fixed → Return to test execution
Checkpoint 1: Failure Understanding
Purpose: Fully understand what the test expects and what went wrong.
Actions:
Read the test code
Understand the test's purpose
Read the error message and stack trace
Understand expected vs actual behavior
Output format:
Debugging Test Failure
CHECKPOINT 1: Failure Understanding
───────────────────────────────────────
Test File: [path/to/test.dart]
Test Name: "[test description]"
Line: [line number]
Test Purpose:
[What behavior is this test validating?]
Expected Behavior:
[What should happen according to the test]
Actual Behavior:
[What actually happened]
Error Message:
[Complete error message]
Stack Trace (key frames):
[Relevant stack trace lines]
Failure Type: [Null safety / Timeout / Expectation mismatch / Widget not found / Other]
Understanding clear? (y/n/need more context)
Wait for user response before proceeding.
Checkpoint 2: Root Cause Hypothesis
Purpose: Form a hypothesis about why the test is failing.
Actions:
Analyze the failure type against known patterns
Check recent code changes that may have caused it
Consider multiple possible causes
Rank by likelihood
Output format:
───────────────────────────────────────
CHECKPOINT 2: Root Cause Hypothesis
Analyzing failure...
Recent Changes (potential causes):
- [file]: [change description] [relevance: High/Medium/Low]
- [file]: [change description] [relevance: High/Medium/Low]
Possible Causes:
1. [Code Issue] - Implementation is incorrect
Evidence: [what suggests this]
Likelihood: [High/Medium/Low]
2. [Test Issue] - Test expectation is wrong
Evidence: [what suggests this]
Likelihood: [High/Medium/Low]
3. [Setup Issue] - Test environment/mock problem
Evidence: [what suggests this]
Likelihood: [High/Medium/Low]
4. [Timing Issue] - Race condition or async problem
Evidence: [what suggests this]
Likelihood: [High/Medium/Low]
Primary Hypothesis: [#X - description]
Reasoning: [Why this is most likely]
Agree with hypothesis? (y/n/suggest alternative)
Wait for user response before proceeding.
Checkpoint 3: Investigation
Purpose: Verify the hypothesis with evidence.
Actions:
Design investigation steps to confirm/reject hypothesis
Execute each step and record findings
Determine if hypothesis is confirmed
If rejected, form new hypothesis
Output format:
───────────────────────────────────────
CHECKPOINT 3: Investigation
Investigation Plan:
Step 1: [What to check]
─────────────────────
Action: [Read file / Run command / Check state]
Expected if hypothesis correct: [what we expect to find]
[Execute step]
Finding: [what was found]
Verdict: [Confirms / Rejects / Inconclusive]
Step 2: [Next check]
─────────────────────
Action: [Read file / Run command / Check state]
Expected if hypothesis correct: [what we expect to find]
[Execute step]
Finding: [what was found]
Verdict: [Confirms / Rejects / Inconclusive]
[... continue investigation steps ...]
Hypothesis Status: [Confirmed / Rejected / Needs revision]
Root Cause: [Confirmed root cause description]
OR
Revised Hypothesis: [New hypothesis if original rejected]
Proceed to fix? (y/n/investigate more)
Wait for user response before proceeding.
Checkpoint 4: Fix Implementation
Purpose: Apply the fix for the confirmed root cause.
Actions:
Determine fix strategy (fix code vs fix test vs fix setup)
Identify files to modify
Implement the fix
Show changes made
Output format:
───────────────────────────────────────
CHECKPOINT 4: Fix Implementation
Root Cause: [confirmed cause]
Fix Strategy: [Fix code / Fix test / Fix setup]
Fix Type:
- [ ] Code fix (implementation was wrong)
- [ ] Test fix (test expectation was wrong)
- [ ] Setup fix (mock/fixture was wrong)
- [ ] Both (code and test needed changes)
Files Modified:
- [file 1]: [change description]
- [file 2]: [change description]
Changes Made:
[file 1]:
[Show the specific changes - before/after or diff summary]
[file 2]:
[Show the specific changes]
Fix applied. Validate the fix? (y/n/revise)
Wait for user response before proceeding.
Checkpoint 5: Fix Validation
Purpose: Verify the fix resolves the issue without regression.
Actions:
Re-run the originally failing test
Run related tests (same file, same component)
Run broader regression check if fix was in production code
Summarize results
Output format:
───────────────────────────────────────
CHECKPOINT 5: Fix Validation
Validation Plan:
1. Re-run failing test (must pass)
2. Run related tests (no regression)
3. Run component tests (broader check)
[4. Run full suite (if critical fix)]
Executing validation...
Phase 1 - Original Test:
[test name]: [PASS/FAIL]
Phase 2 - Related Tests:
[X/X] tests pass
Phase 3 - Component Tests:
[X/X] tests pass
[Phase 4 - Full Suite:]
[X/X] tests pass
Validation Result: [PASSED / FAILED]
[If PASSED:]
Fix validated! ✓
Summary:
- Root cause: [brief description]
- Fix applied: [what was changed]
- Regression check: Clean
Debugging complete! ✓
[If FAILED:]
Fix incomplete - [what still fails]
Options:
1. Revise the fix (go back to CP4)
2. Investigate further (go back to CP3)
3. Abandon and try different approach
Next action? (revise/investigate/new approach)
Wait for user response before proceeding.
Process C: Test Suite Health Check (3 Checkpoints)
Use when: Monitoring test suite quality and identifying improvements.
Checkpoint Flow Overview
Trigger: "Check test suite health" / "Test metrics"
|
Checkpoint 1: Metrics Collection (WAIT)
|
Checkpoint 2: Health Assessment (WAIT)
|
Checkpoint 3: Improvement Plan (WAIT)
|
Health Report Complete
Checkpoint 1: Metrics Collection
Purpose: Gather quantitative data about the test suite.
Actions:
Count total tests by type
Run full suite and measure pass rate
Run coverage analysis
Measure execution time
Identify skipped tests
Output format:
Test Suite Health Check
CHECKPOINT 1: Metrics Collection
───────────────────────────────────────
Running metrics collection...
Test Counts:
Total tests: [X]
Unit tests: [X] ([%])
Widget tests: [X] ([%])
Integration tests: [X] ([%])
Pass Rate:
Passed: [X] / [Total]
Failed: [X]
Skipped: [X]
Pass rate: [X%]
Execution Time:
Total duration: [Xm Ys]
Avg per test: [Xms]
Slowest test: [name] ([Xs])
Coverage:
Overall: [X%]
[Break down by component if available]
Metrics collected. Proceed to assessment? (y/n)
Wait for user response before proceeding.
Checkpoint 2: Health Assessment
Purpose: Evaluate test suite quality from the metrics.
Purpose: Create actionable plan to improve test suite health.
Actions:
Prioritize improvements by impact
Create specific tasks
Estimate effort for each task
Suggest execution order
Output format:
───────────────────────────────────────
CHECKPOINT 3: Improvement Plan
Based on health assessment:
PRIORITY 1 - Fix Now:
1. [ ] [Task] - Impact: [description] - Est: [X hours]
2. [ ] [Task] - Impact: [description] - Est: [X hours]
PRIORITY 2 - Fix Soon:
3. [ ] [Task] - Impact: [description] - Est: [X hours]
4. [ ] [Task] - Impact: [description] - Est: [X hours]
PRIORITY 3 - Backlog:
5. [ ] [Task] - Impact: [description] - Est: [X hours]
6. [ ] [Task] - Impact: [description] - Est: [X hours]
Recommended Targets:
- Pass rate: Maintain >99%
- Coverage: Reach [X%] (current: [Y%])
- Flaky tests: Reduce to 0
- Execution time: Keep under [X minutes]
Create issues for these improvements? (y/n/select items)
Wait for user response before proceeding.
Failure Pattern Recognition
The QA Manager recognizes common failure patterns and provides targeted guidance.
Null Safety Violations
Pattern: "Null check operator used on a null value"
"type 'Null' is not a subtype of type 'X'"
Common Causes:
1. Missing null check in production code
2. Mock not configured to return expected value
3. Test setup missing required field
Investigation Priority:
1. Check the variable that's null in stack trace
2. Trace where it should have been set
3. Check if mock returns null by default
Typical Fix: Add null check or fix mock setup
Timeout Failures
Pattern: "Test timed out after X seconds"
"pumpAndSettle timed out"
Common Causes:
1. Animation or timer preventing pumpAndSettle from completing
2. Async operation never completing
3. Infinite loop in widget rebuild
4. Missing pump() calls
Investigation Priority:
1. Check for animations (use pump(duration) instead of pumpAndSettle)
2. Verify all Futures complete
3. Check for setState loops
4. Run test in isolation
Typical Fix: Replace pumpAndSettle with explicit pump(duration)
Expectation Mismatches
Pattern: "Expected: X Actual: Y"
"Expected [X] items, found [Y]"
Common Causes:
1. Production code changed, test not updated
2. Test expectation was always wrong
3. Order-dependent assertion on unordered data
4. Locale/format difference
Investigation Priority:
1. Check git log for recent changes to tested code
2. Verify the expected value is correct
3. Check if data ordering matters
4. Check locale settings in test
Typical Fix: Update expectation or fix production code
Widget Not Found
Pattern: "No widget found with key [X]"
"Finder found zero widgets"
Common Causes:
1. Widget key changed in production code
2. Widget conditionally hidden (guard clause)
3. Widget not yet rendered (needs pump)
4. Looking in wrong widget subtree
Investigation Priority:
1. Verify key/text exists in current code
2. Check conditional rendering logic
3. Add pump() before finder
4. Check widget tree with debugDumpApp
Typical Fix: Update finder or fix rendering condition
State Management Errors
Pattern: "setState() called after dispose()"
"Looking up a deactivated widget's ancestor"
Common Causes:
1. Async callback fires after widget disposed
2. Timer or stream not cancelled in dispose
3. Test navigates away before async completes
Investigation Priority:
1. Check dispose() method for cleanup
2. Check async callbacks for mounted check
3. Verify test awaits all async operations
Typical Fix: Add mounted check or cancel timers in dispose
See frameworks/failure_patterns.md for the complete catalog.
1. Identify: Run test 10x to confirm flakiness
2. Isolate: Run test alone vs in suite
3. Diagnose: Match symptoms to known causes
4. Fix: Apply targeted fix
5. Verify: Run test 10x again to confirm stability
When fixing a test or production code, assess regression risk:
Change Type
Risk Level
Regression Scope
Test-only fix
Low
Same test file
Model change
Medium
All tests using that model
Service change
Medium-High
Service tests + widget tests using it
Database change
High
All data-dependent tests
UI structure change
Medium
Widget tests for that screen
Regression Test Strategy
Fix Applied
|
├── Re-run failing test (must pass)
|
├── Risk: Low → Run same test file
├── Risk: Medium → Run component tests
├── Risk: High → Run full suite
|
└── Verify: 0 new failures introduced
Regression Checklist
Before marking a fix as complete:
Originally failing test now passes
All tests in the same file pass
All tests in the affected component pass
No new failures in the full suite (for medium+ risk)
Fix documented if it changes behavior
See frameworks/regression_prevention.md for detailed framework.