Validate 79/14/7 test pyramid ratios with pre-push enforcement and reporting.
This skill validates test pyramid balance and enforces pre-push checks for coverage ratios. Target distribution is 79% unit, 14% integration, and 7% end-to-end tests. It ensures fast feedback loops remain dominant without neglecting higher-level verification.
Applies to repositories with multi-layered tests categorized by naming or directory conventions.
Assumes tests can be tagged or grouped into unit, integration, and e2e buckets.
Assumes pre-push hooks can access test counts and coverage metadata.
Target ratios: unit 79%, integration 14%, e2e 7%. Allow a tolerance band of +/- 3 percentage points per bucket. Fail if any bucket exceeds its tolerance band, even if total tests increase. Report ratios by count and by execution time to avoid skewed results.
Unit: single module, mocked dependencies, no network, no filesystem. Integration: multiple modules, real DB or API stub, limited network or filesystem. E2E: real HTTP boundaries, browser or full service chain, production-like data flows. If a test touches more than one external boundary, classify as e2e. If a test relies on a real database, classify as integration.
Run the test ratio check before pushing.
Fail the push if the ratio is outside tolerance.
Print counts, ratios, and suggested actions to correct imbalance.
Store a test-pyramid-report.json artifact with counts per bucket.
Example: python scripts/test_pyramid.py --report test-pyramid-report.json.
Example: jq ".ratios" test-pyramid-report.json to confirm ratios.
Example: rg "@pytest.mark.integration" tests/ to verify tagging.
Pattern: Use folder structure tests/unit, tests/integration, tests/e2e.
Pattern: Use tags like @integration in Jest or pytest.mark.integration in Pytest.
Pattern: Fail pre-push if integration tests exceed 20% to avoid drift.
Pattern: Track execution time by bucket to highlight slow unit tests.
If ratio checks fail unexpectedly, confirm tagging conventions are consistent. If tests are misclassified, update tags before adjusting the ratio thresholds. If e2e tests dominate time, consider splitting into smoke vs full suites. If unit tests are too slow, profile for excessive I/O or heavy fixtures.
The following items are intentionally explicit so the guidance remains actionable and non-generic.