testing-patterns
/testing-patterns
Test pyramid, mocking, fixtures and test organization. Use when designing tests, choosing what to mock or reviewing test quality.
- Author
- jeffersonvalente ↗
- Repository
- cardume ↗
- Licence
- MIT
- Last repository change
- 04.11.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 1
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 04.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 1 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/test_runner.py
What it does and when to use it
Test pyramid, mocking, fixtures and test organization. Use when designing tests, choosing what to mock or reviewing test quality.
Original author description
Test pyramid, mocking, fixtures and test organization. Use when designing tests, choosing what to mock or reviewing test quality.
How it works
- 1. Testing Pyramid
- 2. AAA Pattern
- 3. Test Type Selection
- 4. Unit Test Principles
- 5. Integration Test Principles
- 6. Mocking Principles
- 7. Test Organization
- 8. Test Data
- 9. Best Practices
- 10. Anti-Patterns
SKILL.md preview
---
name: testing-patterns
description: "Test pyramid, mocking, fixtures and test organization. Use when designing tests, choosing what to mock or reviewing test quality."
allowed-tools: Read Write Edit Glob Grep Bash
---
# Testing Patterns
> Principles for reliable test suites.
---
## 1. Testing Pyramid
```
/\ E2E (Few)
/ \ Critical flows
/----\
/ \ Integration (Some)
/--------\ API, DB queries
/ \
/------------\ Unit (Many)
Functions, classes
```
---
## 2. 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.
Files in this package (2)
- SKILL.md 3 KB
- scripts/test_runner.py 7 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · jeffersonvalente/cardume | 100 | MIT |
| Reprograme/redevkit | 100 | MIT |
| piomin/claude-ai-spring-boot | 100 | Apache-2.0 |
| FrancoStino/opencode-skills-collection | 100 | MIT |
| rootcastleco/rei-skills | 100 | MIT |
| davila7/claude-code-templates | 100 | MIT |
| svngoku/coding-agents-skills | 100 | MIT |
| organvm-iv-taxis/a-i--skills | 100 | Apache-2.0 |
| leather-io/mono | 100 | MIT |
Database snapshot: 13.11.2026 · package version 900b994ac46e (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100python-testing-patterns
Guide pytest patterns and testing strategies when the user asks about Python testing, fixtures, mocking, or test organization - 100eng-testing
Use when writing tests, designing test strategy, or reviewing test coverage. Covers test pyramid, naming, mocking, and flaky test policy. - 95pact-testing-strategies
Testing strategies, test pyramid guidance, and quality assurance patterns for PACT Test phase. Use when: designing test suites, implementing unit tests, integration tests, E2E tests, performance testing, security testing, or determining test coverage priorities. Triggers on:… - 80alpha-core:testing-patterns
Provides testing strategies including test pyramid, TDD/BDD, unit/integration/E2E patterns, mocking strategies, test data factories, snapshot testing, and mutation testing. Use when designing test strategies, writing tests, or improving test coverage. - 100testing-strategy
Comprehensive testing methodology, test pyramid, deterministic unit tests, and integration testing. Use when designing test suites or debugging flaky tests. - 100testing-strategies
Testing pyramid, AAA structure, test doubles, fixtures, assertions and coverage targets, in any language. Use when writing, reviewing or setting up tests. Do not use for the write-test-first loop — that is test-driven-development.