testing-patterns
Skill130 starsChanged 10 months agoMITView on GitHub
Testing patterns and principles. Unit, integration, mocking strategies.
Files
Testing Patterns
Principles for reliable test suites.
1. Testing Pyramid
/\ E2E (Few)
/ \ Critical flows
/----\
/ \ Integration (Some)
/--------\ API, DB queries
/ \
/------------\ Unit (Many)
Functions, classes2. AAA Pattern
| Step | Purpose |
| Arrange | Set up test data |
| Act | Execute code under test |
| Assert | Verify outcome |
3. Test Type Selection
When to Use Each
| Type | Best For | Speed |
| Unit | Pure functions, logic | Fast (<50ms) |
| Integration | API, DB, services | Medium |
| E2E | Critical user flows | Slow |
4. Unit Test Principles
Good Unit Tests
| Principle | Meaning |
| Fast | < 100ms each |
| Isolated | No external deps |
| Repeatable | Same result always |
| Self-checking | No manual verification |
| Timely | Written with code |
What to Unit Test
| Test | Don't Test |
| Business logic | Framework code |
| Edge cases | Third-party libs |
| Error handling | Simple getters |
5. Integration Test Principles
What to Test
| Area | Focus |
| API endpoints | Request/response |
| Database | Queries, transactions |
| External services | Contracts |
Setup/Teardown
| Phase | Action |
| Before All | Connect resources |
| Before Each | Reset state |
| After Each | Clean up |
| After All | Disconnect |
6. Mocking Principles
When to Mock
| Mock | Don't Mock |
| External APIs | The code under test |
| Database (unit) | Simple dependencies |
| Time/random | Pure functions |
| Network | In-memory stores |
Mock Types
| Type | Use |
| Stub | Return fixed values |
| Spy | Track calls |
| Mock | Set expectations |
| Fake | Simplified implementation |
7. Test Organization
Naming
| Pattern | Example |
| Should behavior | "should return error when..." |
| When condition | "when user not found..." |
| Given-when-then | "given X, when Y, then Z" |
Grouping
| Level | Use |
| describe | Group related tests |
| it/test | Individual case |
| beforeEach | Common setup |
8. Test Data
Strategies
| Approach | Use |
| Factories | Generate test data |
| Fixtures | Predefined datasets |
| Builders | Fluent object creation |
Principles
- Use realistic data
- Randomize non-essential values (faker)
- Share common fixtures
- Keep data minimal
9. Best Practices
| Practice | Why |
| One assert per test | Clear failure reason |
| Independent tests | No order dependency |
| Fast tests | Run frequently |
| Descriptive names | Self-documenting |
| Clean up | Avoid side effects |
10. Anti-Patterns
| ❌ Don't | ✅ Do |
| Test implementation | Test behavior |
| Duplicate test code | Use factories |
| Complex test setup | Simplify or split |
| Ignore flaky tests | Fix root cause |
| Skip cleanup | Reset state |
Remember: Tests are documentation. If someone can't understand what the code does from the tests, rewrite them.
Other versions43 projects use a version of this.
Word for word · 2
- VoDaiLocz/kilo-kit-mcp★ 26100% same
- sid-lakhani/agents-config★ 2100% same
Edited · 5
- vudovn/ag-kit★ 8.2k92% same
- vudovn/antigravity-kit★ 8.2k92% same
- soumatheusgomes/agentville★ 989% same
- SKB3002/agenthub★ 485% same
- jornalistainclusivo/jinc-skills★ 1100% same
Wrote their own version · 36
- ChrisWiles/claude-code-showcase★ 6.1ksame name
- ag2ai/faststream★ 5.4ksame name
- piomin/claude-ai-spring-boot★ 1.4ksame name
- bybren-llc/safe-agentic-workflow★ 405same name
- dilolabs/nosia★ 214same name
- langchain-ai/skills-benchmarks★ 116same name
- leather-io/mono★ 28same name
- 4444J99/a-i--skills★ 17same name
- organvm-iv-taxis/a-i--skills★ 17same name
- wpank/ai★ 11same name
26 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use intelligent-routing, formik-patterns and 4 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SKB3002Skillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 5 projects that use this
ChrisWilesSkillformik-patterns
Formik form handling with validation patterns. Use when building forms, implementing validation, or handling form submission.
Also in 3 projects that use this
SKB3002Skillnextjs-react-expert
React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.
Also in 3 projects that use this
adybaSkillsafe-workflow
SAFe Agentic Workflow orchestrator. Teaches the full SAFe methodology adapted for AI agents: pattern discovery, exit states, quality gates, agent personas, and specs-driven development. Use when setting up a project with SAFe workflow, understanding the multi-agent methodology, or coordinating work across agent personas. Triggers: "SAFe workflow", "agent workflow", "safe harness", "specs-driven", "exit states", "quality gates", "multi-agent workflow".
Also in 3 projects that use this
adybaSkillspec-creation
Spec creation with pattern references, acceptance criteria, and demo scripts. Use when creating implementation specs, defining acceptance criteria, breaking down user stories, or translating business requirements to technical specs. Do NOT use for implementation work -- this is for planning and specification only.
Also in 3 projects that use this
xfstudioSkillrust-pro
Master Rust 1.75+ with modern async patterns, advanced type system
Also in 5 projects that use this
In this repository45 other files it gives its agents.
- api-patternsSkill
- app-builderSkill
- templatesSkill
- architectureSkill
- bash-linuxSkill
- behavioral-modesSkill
- brainstormingSkill
- clean-codeSkill
- code-review-checklistSkill
- database-designSkill
- deployment-proceduresSkill
- documentation-templatesSkill
- frontend-designSkill
- 2d-gamesSkill
- 3d-gamesSkill
- game-artSkill
- game-audioSkill
- game-designSkill
- mobile-gamesSkill
- multiplayerSkill
- pc-gamesSkill
- game-developmentSkill
- vr-arSkill
- web-gamesSkill
- geo-fundamentalsSkill
- i18n-localizationSkill
- lint-and-validateSkill
- mcp-builderSkill
- mobile-designSkill
- nextjs-best-practicesSkill
- nodejs-best-practicesSkill
- parallel-agentsSkill
- performance-profilingSkill
- plan-writingSkill
- powershell-windowsSkill
- python-patternsSkill
- react-patternsSkill
- red-team-tacticsSkill
- seo-fundamentalsSkill
- server-managementSkill
- systematic-debuggingSkill
- tailwind-patternsSkill
- tdd-workflowSkill
- vulnerability-scannerSkill
- webapp-testingSkill
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.

