test-strategy-selection
Skill2 starsChanged 2 months agoMITView on GitHub
Choose the right type of tests — unit, integration, contract, e2e, static — based on risk, context, and ROI.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- journal-management-genericSkill
- simplified-technical-englishSkill
- code-implementationSkill
- python-quality-gatesSkill
- journal-managementSkill
- plan-trackingSkill
- project-notesSkill
- task-routingSkill
- herdrSkill
- plan-output-templateSkill
- risk-and-dependency-identificationSkill
- task-decompositionSkill
- source-selectionSkill
- code-review-checklistSkill
- production-issue-flaggingSkill
- regression-identificationSkill
- test-case-structureSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 105
Greenfield: Start with pyramid (70/20/10).
- Distinctive: line 107
Legacy (untested): Write a test before every bug fix.
- Distinctive: line 132
Use as signals, not goals:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Test Strategy Selection
Test Types
| Type | What It Tests | Speed | Confidence | Cost |
| Static analysis | Types, lint, dead code | ⚡ Instant | Low | $0 |
| Unit | Single function/class in isolation | ⚡ ms | Low–Medium | $ |
| Integration | Multiple components working together | 🐢 seconds | High | $$ |
| Contract | Service boundary compatibility | 🐢 seconds | Medium–High | $$ |
| End-to-end | Full user flow through the system | 🐌 minutes | Highest | $$$$ |
The Push-Down Principle
Write tests at the lowest level that gives you the confidence you need.
Is a unit test enough?
YES → Write unit test
NO → Is an integration test enough?
YES → Write integration test
NO → Write E2E testUnnecessary elevation adds cost and fragility without adding confidence.
Decision Framework: Which Test Type When?
| Question | Test Type |
| "Does this function do what I expect?" | Unit |
| "Do these components work together?" | Integration |
| "Is my API contract still compatible?" | Contract |
| "Can a user actually do this thing?" | E2E |
| "Is my code well-typed and lint-free?" | Static |
| "Is this performance-sensitive path fast enough?" | Benchmark |
| "Is the migration reversible?" | Integration |
Risk-Based Framework
Step 1: Rate the Risk
| Dimension | 1 (Low) | 2 (Medium) | 3 (High) | 4 (Critical) |
| Business Impact | Cosmetic, rarely used | Minor feature | Core feature, revenue-impacting | Safety-critical, financial, PII |
| Failure Probability | Stable, tested | Occasional changes | High churn, complex logic | New code, external deps, concurrency |
Step 2: Score = Business Impact × Failure Probability
| Score | Testing Requirement |
| 1-4 | Minimal — smoke tests, unit only |
| 5-6 | Standard — unit + integration |
| 7-9 | Thorough — unit + integration + contract |
| 10-16 | Extensive — unit + integration + contract + E2E |
Step 3: Allocate Effort
| Category | Budget | Examples |
| 🔴 Critical (10-16) | 40% | Payment, auth, data integrity |
| 🟠 High (7-9) | 30% | Search, user management |
| 🟡 Medium (5-6) | 20% | Profiles, notifications |
| 🟢 Low (1-4) | 10% | Admin panels, logging |
Cost/Benefit Reference
| Dimension | Unit | Integration | Contract | E2E |
| Execution speed | ⚡ ms | 🐢 seconds | 🐢 seconds | 🐌 minutes |
| Write cost | $ | $$ | $$ | $$$$ |
| Maintenance cost | $ | $$ | $ | $$$$ |
| Debugging signal | ✅ Precise | ✅ Good | ✅ Good | ❌ Noisy |
| Flakiness | 🟢 Very low | 🟢 Low | 🟢 Very low | 🔴 High |
Test Shapes
| Shape | Ratio | Best For |
| Pyramid | 70% Unit / 20% Integration / 10% E2E | Monoliths, logic-heavy apps |
| Trophy | Static + Unit + fat Integration + thin E2E | Component-driven frontends |
| Honeycomb | Many Integration + Contract, few Unit + E2E | Microservices |
The shape debate is mostly semantic. What matters: tests are fast, reliable, and catch meaningful failures.
Strategy by Codebase Context
Greenfield: Start with pyramid (70/20/10). Invest in test infrastructure early — Testcontainers, CI pipeline, sharding.
Legacy (untested): Write a test before every bug fix; write a test before every refactor; start with integration tests — they give more value when boundaries are unclear.
Monolith: Classic pyramid. Resist the temptation to write E2E tests because they're "easy."
Microservices: Contract testing is the linchpin. Unit + Contract dominate; minimize E2E.
CI/CD Integration
| Trigger | Tests to Run |
| Every commit (branch) | Lint, unit, type check |
| Pull request open/update | + Integration, impact-analyzed regression |
| Merge to main | + Contract, component tests |
| Deploy to staging | + E2E (critical paths) |
| Deploy to production | + Smoke tests |
Hard gates (pipeline fails): test failures, critical security vulns, build errors. Soft gates (warning only): coverage drops, medium-severity findings.
Coverage Targets
Use as signals, not goals:
| Code Type | Target | Test Level |
| Business logic | 90%+ branch | Unit |
| API handlers | 80%+ line | Unit + Integration |
| Utility/pure functions | 95%+ | Unit |
| Critical UI components | 60%+ | Integration |
Speed budgets:
- Unit: < 30s total, < 10ms per test
- Integration: < 3min total, 50-500ms per test
- E2E: < 10min total, 2-30s per test
Core Rules
- Mock external deps in unit tests; use real ones in integration tests.
- Coverage is a signal, not a goal — 100% with no assertions is worthless.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

