Extract and Summarize Test Failures
Parse test logs to extract failure information and create summary.
When to Use
- •CI test run failed, need to understand failures
- •Large test suite with many failures, need summary
- •Categorizing failures by type (assertion, runtime, timeout)
- •Creating PR review comments about failures
- •Tracking which tests are failing over time
Quick Reference
bash
# Extract failed test names grep "FAILED" test_output.log # Get failure details with context grep -A 10 "FAILED\|Error\|AssertionError" test_output.log # Count failures by type grep "FAILED\|AssertionError\|ValueError\|TypeError" test_output.log | sort | uniq -c # Extract test summary line tail -20 test_output.log | grep -E "passed|failed|error" # Get specific failure info grep -B 5 "AssertionError" test_output.log | head -50
Failure Extraction Workflow
- •Collect log: Get test output from CI or local run
- •Find failures: Extract FAILED markers and error types
- •Group by type: Categorize assertion vs runtime vs timeout
- •Extract details: Get error messages and stack traces
- •Count totals: Summary of how many failures
- •Identify patterns: Common failure causes
- •Summarize: Create concise failure report
Failure Categories
Assertion Failures:
- •
AssertionError- Expected value check failed - •
assert_equal()- Values don't match - •
assert_true()- Condition not true - •Fix: Check test logic and expected values
Type/Attribute Errors:
- •
AttributeError- Missing method/attribute - •
TypeError- Wrong argument type - •
ValueError- Invalid value for operation - •Fix: Check code syntax and types
Runtime Errors:
- •
IndexError- Out of bounds access - •
KeyError- Dictionary key not found - •
ZeroDivisionError- Division by zero - •Fix: Check boundary conditions
Timeout/Hanging:
- •Test takes too long
- •Infinite loop or deadlock
- •Resource exhaustion
- •Fix: Optimize or add timeout
Output Format
Report failures with:
- •Total Failures - Count and percentage of total tests
- •Failure Summary - By type (assertion, runtime, timeout, other)
- •Failed Tests - List of test names that failed
- •Top Issues - Most common failure patterns
- •Error Messages - Representative error snippets
- •Recommendations - Which tests to focus on first
Error Handling
| Problem | Solution |
|---|---|
| No FAILED markers | Check log format, may use different pattern |
| Truncated output | Get full log from artifacts instead of view |
| Mixed output types | Filter by log level or timestamp |
| Encoding issues | Convert to UTF-8 first |
| Very large logs | Split and process in chunks |
References
- •See test-diff-analyzer for identifying flaky tests
- •See analyze-ci-failure-logs for CI-specific failures
- •See generate-fix-suggestions for automated fixes