agentleFS
las-pinterlas-pinter/persona-agents/skills/tester/test-strategy-selection/SKILL.md

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.

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
  1. Very specific:

    Greenfield: Start with pyramid (70/20/10).

    line 105
  2. Distinctive:

    Legacy (untested): Write a test before every bug fix.

    line 107
  3. Distinctive:

    Use as signals, not goals:

    line 132

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Test Strategy Selection

Test Types

TypeWhat It TestsSpeedConfidenceCost
Static analysisTypes, lint, dead code⚡ InstantLow$0
UnitSingle function/class in isolation⚡ msLow–Medium$
IntegrationMultiple components working together🐢 secondsHigh$$
ContractService boundary compatibility🐢 secondsMedium–High$$
End-to-endFull user flow through the system🐌 minutesHighest$$$$

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 test

Unnecessary elevation adds cost and fragility without adding confidence.


Decision Framework: Which Test Type When?

QuestionTest 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

Dimension1 (Low)2 (Medium)3 (High)4 (Critical)
Business ImpactCosmetic, rarely usedMinor featureCore feature, revenue-impactingSafety-critical, financial, PII
Failure ProbabilityStable, testedOccasional changesHigh churn, complex logicNew code, external deps, concurrency

Step 2: Score = Business Impact × Failure Probability

ScoreTesting Requirement
1-4Minimal — smoke tests, unit only
5-6Standard — unit + integration
7-9Thorough — unit + integration + contract
10-16Extensive — unit + integration + contract + E2E

Step 3: Allocate Effort

CategoryBudgetExamples
🔴 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

DimensionUnitIntegrationContractE2E
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

ShapeRatioBest For
Pyramid70% Unit / 20% Integration / 10% E2EMonoliths, logic-heavy apps
TrophyStatic + Unit + fat Integration + thin E2EComponent-driven frontends
HoneycombMany Integration + Contract, few Unit + E2EMicroservices

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

TriggerTests 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 TypeTargetTest Level
Business logic90%+ branchUnit
API handlers80%+ lineUnit + Integration
Utility/pure functions95%+Unit
Critical UI components60%+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

  1. Mock external deps in unit tests; use real ones in integration tests.
  2. Coverage is a signal, not a goal — 100% with no assertions is worthless.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.