Skip to main content
ClaudeWave
Skill355 estrellas del repoactualizado today

testing-patterns

testing-patterns provides cross-language testing strategies covering the test pyramid, unit/integration/end-to-end test types, naming conventions, the arrange-act-assert pattern, test doubles, and database isolation approaches. Use this skill when designing test suites, implementing TDD or BDD practices, establishing test coverage standards, creating mocking strategies, or establishing test isolation methods across different programming languages and frameworks.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/aiskillstore/marketplace /tmp/testing-patterns && cp -r /tmp/testing-patterns/skills/0xdarkmatter/testing-patterns ~/.claude/skills/testing-patterns
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# Testing Patterns

Universal testing strategies and patterns applicable across languages.

## The Test Pyramid

```
        /\
       /  \     E2E Tests (few, slow, expensive)
      /    \    - Full system tests
     /------\   - Real browser/API calls
    /        \
   /  Integ   \ Integration Tests (some)
  /   Tests    \ - Service boundaries
 /--------------\ - Database, APIs
/                \
/   Unit Tests    \ Unit Tests (many, fast, cheap)
------------------  - Single function/class
                    - Mocked dependencies
```

## Test Types

### Unit Tests
```
Scope:      Single function/method/class
Speed:      Milliseconds
Dependencies: All mocked
When:       Every code change
Coverage:   80%+ of codebase
```

### Integration Tests
```
Scope:      Multiple components together
Speed:      Seconds
Dependencies: Real databases, mocked external APIs
When:       PR/merge, critical paths
Coverage:   Key integration points
```

### End-to-End Tests
```
Scope:      Full user journey
Speed:      Minutes
Dependencies: Real system (or staging)
When:       Pre-deploy, nightly
Coverage:   Critical user flows only
```

## Test Naming Convention

```
test_<unit>_<scenario>_<expected>

Examples:
- test_calculate_total_with_discount_returns_reduced_price
- test_user_login_with_invalid_password_returns_401
- test_order_submit_when_out_of_stock_raises_error
```

## Arrange-Act-Assert (AAA)

```python
def test_calculate_discount():
    # Arrange - Set up test data and dependencies
    cart = Cart()
    cart.add_item(Item(price=100))
    discount = Discount(percent=10)

    # Act - Execute the code under test
    total = cart.calculate_total(discount)

    # Assert - Verify the results
    assert total == 90
```

## Test Doubles

| Type | Purpose | Example |
|------|---------|---------|
| **Stub** | Returns canned data | `stub.get_user.returns(fake_user)` |
| **Mock** | Verifies interactions | `mock.send_email.assert_called_once()` |
| **Spy** | Records calls, uses real impl | `spy.on(service, 'save')` |
| **Fake** | Working simplified impl | `FakeDatabase()` instead of real DB |
| **Dummy** | Placeholder, never used | `null` object for required param |

## Test Isolation Strategies

### Database Isolation
```
Option 1: Transaction rollback (fast)
- Start transaction before test
- Rollback after test

Option 2: Truncate tables (medium)
- Clear all data between tests

Option 3: Separate database (slow)
- Each test gets fresh database
```

### External Service Isolation
```
Option 1: Mock at boundary
- Replace HTTP client with mock

Option 2: Fake server
- WireMock, MSW, VCR cassettes

Option 3: Contract testing
- Pact, consumer-driven contracts
```

## What to Test

### MUST Test
- Business logic and calculations
- Input validation and error handling
- Security-sensitive code (auth, permissions)
- Edge cases and boundary conditions

### SHOULD Test
- Integration points (DB, APIs)
- State transitions
- Configuration handling

### AVOID Testing
- Framework internals
- Third-party library behavior
- Simple getters/setters
- Private implementation details

## Test Quality Checklist

- [ ] Tests are independent (no order dependency)
- [ ] Tests are deterministic (no flaky tests)
- [ ] Tests are fast (unit < 100ms, integration < 5s)
- [ ] Tests have clear names describing behavior
- [ ] Tests cover happy path AND error cases
- [ ] Tests don't repeat production logic
- [ ] Mocks are minimal (only external boundaries)

## Additional Resources

- `./references/tdd-workflow.md` - Test-Driven Development cycle
- `./references/mocking-strategies.md` - When and how to mock
- `./references/test-data-patterns.md` - Fixtures, factories, builders
- `./references/ci-testing.md` - Testing in CI/CD pipelines

## Scripts

- `./scripts/coverage-check.sh` - Run coverage and fail if below threshold
jira-safeSkill

Implement SAFe methodology in Jira. Use when creating Epics, Features, Stories with proper hierarchy, acceptance criteria, and parent-child linking.

jira-workflowSkill

Orchestrate Jira workflows end-to-end. Use when building stories with approvals, transitioning items through lifecycle states, or syncing task completion with Jira.

chinese-learning-assistantSkill

HSK4級レベルから流暢さを目指す学習者向け。中国語表現の使用場面・自然さを分析し、作文を「ネイティブらしい流暢な表現」に改善。bilibili等のコンテンツ理解とネイティブとの会話をサポート。実際の用例をWeb検索で提示

frontend-dev-guidelinesSkill

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

skill-developerSkill

Claude Code 스킬, 훅, 에이전트, 명령어를 생성하고 관리하기 위한 메타 스킬. 새 스킬 생성, 스킬 트리거 설정, 훅 설정, Claude Code 인프라 관리 시 사용.

sitemapkitSkill

Discover and extract sitemaps from any website using SitemapKit. Use this skill whenever the user wants to find pages on a website, get a list of URLs from a domain, audit a site's structure, crawl a sitemap, check what pages exist on a site, or do anything involving sitemaps or site URL discovery — even if they don't explicitly say "sitemap". Requires the sitemapkit MCP server configured with a valid SITEMAPKIT_API_KEY.

create-prSkill

GitHubのプルリクエスト(PR)を作成する際に使用します。変更のコミット、プッシュ、PR作成を含む完全なワークフローを日本語で実行します。「PRを作って」「プルリクエストを作成」「pull requestを作成」などのリクエストで自動的に起動します。

create-svg-from-promptSkill

Generate an SVG of a user-requested image or scene