Quantify and prioritize test technical debt by analyzing coverage gaps, flaky test ratios, outdated assertions, and missing test categories across codebases.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Instruções da origem · Visualização somente leitura
name
Test Debt Calculator
description
Quantify and prioritize test technical debt by analyzing coverage gaps, flaky test ratios, outdated assertions, and missing test categories across codebases.
Test technical debt is the accumulated cost of shortcuts, neglect, and decay in a test suite over time. Unlike application technical debt, test debt is insidious because it silently erodes confidence in deployments without producing visible bugs. A team with 80% code coverage might still have massive test debt if that coverage is concentrated on trivial paths, if 15% of tests are flaky, or if assertions are testing implementation details rather than behavior. This skill provides a systematic framework for quantifying test debt across multiple dimensions, prioritizing remediation efforts, and integrating debt tracking into your development workflow so that test quality improves continuously rather than degrading silently.
Core Principles
1. Test Debt Is Measurable
Test debt is not a vague feeling; it is a collection of concrete, measurable metrics. Coverage gaps, flaky test ratios, test execution time regression, assertion staleness, and missing test categories can all be quantified with automated tooling. The first step to reducing test debt is measuring it with precision.
2. Not All Debt Is Equal
A missing integration test for a payment processing endpoint is fundamentally different from a missing unit test for a string formatting utility. Test debt must be weighted by the risk and business impact of the uncovered or poorly covered code. A risk-weighted model ensures remediation effort goes where it matters most.
3. Debt Accumulates Compounding Interest
Ignoring test debt does not keep it constant; it grows. Flaky tests slow down CI, which encourages developers to skip tests, which creates more coverage gaps, which leads to more production bugs, which erodes trust in testing itself. Breaking this cycle requires proactive measurement and remediation before the debt compounds beyond the team's capacity to address it.
4. Track Trends, Not Snapshots
A single debt measurement tells you where you are. Trend data tells you where you are heading. Track test debt metrics over time to distinguish between "we have debt but it is shrinking" and "we have debt and it is growing." Trend direction is more important than absolute numbers.
5. Automate the Calculation
Manual test debt assessments happen infrequently and become outdated quickly. Automated calculation integrated into CI ensures that every pull request and every sprint has up-to-date debt metrics available without any manual effort.
The src/analyzers/ directory contains one analyzer per debt dimension. The src/collectors/ directory provides framework-specific adapters for extracting raw data from Jest, Vitest, and Pytest. The src/scoring/ directory contains the composite scoring logic and risk weight configuration. The src/reporters/ directory formats debt reports for various output targets.
Debt Dimensions
Test debt is not a single number. It is a multi-dimensional assessment across these categories:
1. Coverage Gaps
Coverage gap analysis goes beyond simple percentage checks. It identifies which specific files and functions lack coverage, weights them by business risk, and produces a prioritized list of gaps to address:
Flaky tests are the most damaging form of test debt because they undermine trust in the entire suite. The flaky analyzer tracks tests that produce inconsistent results across multiple runs:
Run debt calculations on every pull request. Integrate the debt calculator into your CI pipeline so that every PR shows its impact on test debt. This prevents gradual accumulation and creates accountability.
Set debt thresholds and enforce them in CI. Define a maximum acceptable debt score and fail the CI build if it is exceeded. Start with a lenient threshold and tighten it gradually as the team reduces existing debt.
Weight dimensions by business impact. Coverage gaps in payment processing code matter more than coverage gaps in utility functions. Configure risk weights to reflect your domain's risk profile.
Track debt trends over time, not just current state. A score of 0.3 that was 0.5 last month is a success story. Store snapshots and compare across runs to recognize progress and identify regression.
Distinguish between intentional and accidental debt. Some test debt is a conscious decision. Document intentional debt separately from accidental debt so that the team does not waste effort re-evaluating accepted trade-offs.
Review the debt report in sprint retrospectives. Make test debt a recurring agenda item. Teams that discuss debt regularly reduce it faster than teams that only measure it.
Prioritize flaky test remediation above all else. Flaky tests have the highest compound interest rate because they erode developer trust in the entire test suite. Fix flaky tests before adding new coverage.
Use the test pyramid as a diagnostic tool. If your category analysis reveals an inverted pyramid with more e2e tests than unit tests, your suite is likely slow, brittle, and expensive to maintain.
Correlate debt scores with production incidents. Track whether modules with high test debt scores produce more production bugs. This data justifies remediation investment to stakeholders and product managers.
Automate test classification. Manually categorizing tests as unit, integration, or e2e is error-prone. Use file path conventions, test runner tags, or AST analysis to automate classification consistently.
Set per-module debt budgets. Different modules may have different acceptable debt levels. Core modules should have near-zero debt; experimental features may tolerate higher debt temporarily.
Include test duration in the debt calculation. A test suite that takes 45 minutes to run has duration debt. Slow suites discourage frequent testing and slow down CI feedback loops.
Anti-Patterns to Avoid
Optimizing for coverage percentage alone. A codebase can have 90% line coverage and still have massive test debt if that coverage consists of trivial assertions, tests implementation details, or ignores branch coverage entirely. Coverage is one input to the debt calculation, not the entire picture.
Treating all test files equally. A stale test file for a payment processing module is far more concerning than a stale test for a logging utility. Always apply risk-weighted scoring so that remediation effort targets the highest-impact areas first.
Calculating debt without acting on it. Measurement without remediation is just overhead. Every debt report should produce actionable work items with clear ownership and timelines. If reports accumulate without action, they lose credibility.
Using debt calculations to blame individuals. Debt accumulates over time through collective decisions and organizational pressures. Using debt metrics punitively discourages transparency and encourages gaming the metrics rather than improving quality.
Ignoring the test pyramid. A suite with 500 e2e tests and 50 unit tests will be slow, brittle, and expensive to maintain. Category analysis should inform architectural decisions about where to invest testing effort.
Setting unrealistic debt targets. Zero debt is not achievable or desirable. Some debt is a rational trade-off. Set targets that are ambitious but achievable, and adjust them based on team capacity and business priorities.
Running debt calculations only quarterly. Infrequent measurement leads to surprise debt spikes. Integrate debt calculation into CI for continuous visibility so that debt never accumulates unnoticed.
Debugging Tips
Coverage data is missing or incomplete. Verify that your test runner is configured to collect coverage. For Jest, add --coverage --coverageReporters=json to your test command. For Vitest, configure coverage.reporter to include json. Ensure the output file path matches what the debt calculator expects.
Flaky analysis shows zero flaky tests. The flaky analyzer requires historical run data across multiple executions. A single test run cannot identify flaky tests. Collect and store test run records across at least 10-20 CI runs before expecting meaningful flaky analysis results.
Staleness scores seem too high. Check the maxAcceptableAgeDays parameter. For rapidly evolving codebases, 90 days may be appropriate. For stable libraries, 365 days may be more realistic. Calibrate thresholds to match your development velocity.
Category classification is inaccurate. Review the classification logic. File path-based classification works well for conventional project structures but fails for non-standard layouts. Consider adding explicit tags or annotations to test files for accurate categorization.
Debt score does not correlate with team perception. Calibrate the dimension weights. If the team perceives flaky tests as the biggest problem but coverage gaps score higher, increase the flaky dimension weight. The model should reflect your team's lived experience.
CI build fails on debt threshold. If the threshold is newly introduced, start with a lenient value such as 0.7 and tighten it by 0.05 each sprint. This gives the team time to reduce existing debt without blocking all development work.