Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Testing Patterns

ASecurity

Cross-language testing strategies and patterns. Triggers on: test pyramid, unit test, integration test, e2e test, TDD, BDD, test coverage, mocking strategy, test doubles, test isolation.

416 stars
0 votes
0 copies
2 views
Added 2/7/2026
developmentpythonbashtestingapidatabaseci/cdsecurity

Works with

cliapi

Security Analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned 2/12/2026

$npx -y skills add aiskillstore/marketplace --skill testing-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Testing Patterns?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Testing Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aiskillstore-testing-patterns/badge)](https://www.skillsdirectory.com/skills/aiskillstore-testing-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: testing-patterns
description: "Cross-language testing strategies and patterns. Triggers on: test pyramid, unit test, integration test, e2e test, TDD, BDD, test coverage, mocking strategy, test doubles, test isolation."
compatibility: "Language-agnostic patterns. Framework-specific details in references."
allowed-tools: "Read Write Bash"
---

# 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

Attribution

aiskillstoreaiskillstore
View sourceSee grades on GitHubMore from aiskillstore →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Clean Code

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

304955 votes

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

285172 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

10341 votes
View all in development →