test-pyramid-design

Design optimal test pyramids with unit/integration/E2E ratios. Identify anti-patterns and recommend architecture-specific testing strategies.

16 stars

Best use case

test-pyramid-design is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Design optimal test pyramids with unit/integration/E2E ratios. Identify anti-patterns and recommend architecture-specific testing strategies.

Teams using test-pyramid-design should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/test-pyramid-design/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/design/test-pyramid-design/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/test-pyramid-design/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How test-pyramid-design Compares

Feature / Agenttest-pyramid-designStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Design optimal test pyramids with unit/integration/E2E ratios. Identify anti-patterns and recommend architecture-specific testing strategies.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Test Pyramid Design

## When to Use This Skill

Use this skill when:

- **Test Pyramid Design tasks** - Working on design optimal test pyramids with unit/integration/e2e ratios. identify anti-patterns and recommend architecture-specific testing strategies
- **Planning or design** - Need guidance on Test Pyramid Design approaches
- **Best practices** - Want to follow established patterns and standards

## Overview

The Test Pyramid, introduced by Mike Cohn, visualizes the ideal distribution of tests across different levels. More granular tests at the bottom (fast, cheap) and fewer broad tests at the top (slow, expensive).

## The Classic Test Pyramid

```text
                    ┌───────┐
                   /  E2E    \         ~10%
                  /   Tests   \        (UI, Acceptance)
                 /─────────────\
                /  Integration  \      ~20%
               /     Tests       \     (API, Component)
              /───────────────────\
             /      Unit Tests     \   ~70%
            /       (Fast, Cheap)   \  (Methods, Classes)
           └─────────────────────────┘
```

## Test Level Characteristics

| Level | Speed | Cost | Scope | Confidence | Maintenance |
|-------|-------|------|-------|------------|-------------|
| Unit | Fastest (ms) | Lowest | Single unit | Low | Low |
| Integration | Medium (s) | Medium | Components | Medium | Medium |
| E2E | Slowest (min) | Highest | Full system | High | High |

## Common Pyramid Shapes

### Healthy Pyramid ✅

```text
     /\          Unit: 70%+
    /  \         Integration: 20%
   /    \        E2E: 10%
  /      \
 /________\      Fast feedback, low maintenance
```

**Characteristics**:

- Fast CI/CD pipeline
- Quick feedback loop
- Low flakiness
- Easy maintenance

### Ice Cream Cone ❌

```text
   ██████████     E2E: 60%
    ████████      Integration: 30%
      ████        Unit: 10%
```

**Problems**:

- Slow pipelines (hours)
- Flaky tests
- Expensive maintenance
- Late feedback

**Fix**: Extract unit tests, reduce E2E scope

### Cupcake ❌

```text
   ██████████     E2E: 40%
   ██████████     Manual: 50%
      ████        Unit: 10%
```

**Problems**:

- High manual testing cost
- Inconsistent coverage
- Slow release cycles

**Fix**: Automate critical paths, add integration layer

### Hourglass ❌

```text
      ██          E2E: 10%
   ██████████     Integration: 70%
      ██          Unit: 20%
```

**Problems**:

- Slow integration tests
- Brittle test fixtures
- Missing unit test coverage

**Fix**: Push coverage down to unit level

## Architecture-Specific Pyramids

### Monolithic Application

```text
     /\          Unit: 70%
    /  \         Integration: 20%
   /    \        E2E: 10%
  /______\
```

Focus on unit tests for business logic.

### Microservices

```text
     /\          E2E/Contract: 10%
    /  \         Integration: 30%
   /    \        Unit: 60%
  /______\
```

More integration tests for service boundaries.
Add contract tests between services.

### Event-Driven Architecture

```text
     /\          E2E: 10%
    /  \         Integration: 35%
   /    \        Unit: 55%
  /______\
```

Integration tests for event handlers.
Unit tests for event processing logic.

### Frontend-Heavy (SPA)

```text
     /\          E2E: 15%
    /  \         Integration: 25%
   /    \        Unit/Component: 60%
  /______\
```

Component tests replace some unit tests.
Visual regression testing at integration level.

## Testing Trophy (Kent C. Dodds)

Alternative for frontend applications:

```text
                 ┌─────┐
                 │ E2E │              ~5%
              ┌──┴─────┴──┐
              │Integration│           ~50%
           ┌──┴───────────┴──┐
           │    Static        │       ~10%
        ┌──┴─────────────────┴──┐
        │        Unit            │    ~35%
        └────────────────────────┘
```

## Designing Your Pyramid

### Step 1: Assess Current State

Count tests by level:

```text
Level        | Count | % Total | Time    | Pass Rate
-------------|-------|---------|---------|----------
E2E          | 150   | 45%     | 30 min  | 85%
Integration  | 100   | 30%     | 10 min  | 95%
Unit         | 80    | 25%     | 30 sec  | 99%
```

### Step 2: Identify Anti-Pattern

| If You Have... | Shape | Priority Fix |
|----------------|-------|--------------|
| E2E > 30% | Ice Cream Cone | Extract to lower levels |
| Unit < 50% | Inverted | Add unit tests for logic |
| Integration > 50% | Hourglass | Push to unit level |
| Manual > 20% | Cupcake | Automate critical paths |

### Step 3: Set Target Ratios

Based on architecture:

| Architecture | Unit | Integration | E2E |
|--------------|------|-------------|-----|
| Monolith | 70% | 20% | 10% |
| Microservices | 60% | 30% | 10% |
| Serverless | 50% | 40% | 10% |
| Frontend SPA | 40% | 45% | 15% |

### Step 4: Migration Plan

Prioritize by ROI:

1. **Quick wins**: Convert flaky E2E to integration
2. **Coverage gaps**: Add unit tests for critical logic
3. **Contract tests**: Add for service boundaries
4. **Remove duplicates**: Consolidate redundant E2E tests

## Test Level Guidelines

### Unit Tests

**Should test**:

- Business logic
- Algorithms
- Data transformations
- Validation rules
- Edge cases

**Should NOT test**:

- External services
- Database queries
- File system operations
- Third-party libraries

### Integration Tests

**Should test**:

- Database repository operations
- API endpoints
- Message handlers
- External service adapters
- Component interactions

**Should NOT test**:

- Pure business logic (use unit tests)
- Full user journeys (use E2E)

### E2E Tests

**Should test**:

- Critical user journeys
- Happy paths
- Smoke tests
- Cross-system workflows

**Should NOT test**:

- Edge cases (use unit tests)
- API contracts (use integration tests)
- Everything (be selective)

## .NET Example: Test Project Structure

```text
src/
  MyApp.Domain/           # Business logic
  MyApp.Application/      # Use cases
  MyApp.Infrastructure/   # Data access
  MyApp.Api/              # HTTP endpoints

tests/
  MyApp.Domain.Tests/           # Unit tests (70%)
    Features/
      Orders/
        CreateOrderTests.cs
        OrderValidationTests.cs

  MyApp.Application.Tests/      # Integration tests (20%)
    Features/
      Orders/
        CreateOrderHandlerTests.cs

  MyApp.Api.Tests/              # E2E tests (10%)
    Features/
      Orders/
        OrdersEndpointTests.cs
```

### Test Distribution Verification

```csharp
// Build script or CI check
public class TestDistributionTests
{
    [Fact]
    public void TestPyramidRatiosAreHealthy()
    {
        var unitTests = CountTestsInAssembly("MyApp.Domain.Tests");
        var integrationTests = CountTestsInAssembly("MyApp.Application.Tests");
        var e2eTests = CountTestsInAssembly("MyApp.Api.Tests");

        var total = unitTests + integrationTests + e2eTests;

        Assert.True(unitTests / total >= 0.60, "Unit tests should be ≥60%");
        Assert.True(e2eTests / total <= 0.15, "E2E tests should be ≤15%");
    }
}
```

## Metrics and Monitoring

### Pipeline Health

| Metric | Healthy | Warning | Critical |
|--------|---------|---------|----------|
| Unit test time | < 1 min | 1-5 min | > 5 min |
| Integration time | < 5 min | 5-15 min | > 15 min |
| E2E test time | < 10 min | 10-30 min | > 30 min |
| Flaky test rate | < 1% | 1-5% | > 5% |

### Coverage Balance

Track coverage by pyramid level:

- Unit coverage of business logic: ≥90%
- Integration coverage of APIs: ≥80%
- E2E coverage of critical paths: 100%

## Integration Points

**Inputs from**:

- Architecture documents → Pyramid shape
- Risk assessment → E2E scope

**Outputs to**:

- `test-strategy-planning` skill → Strategy document
- CI/CD configuration → Pipeline stages
- `automation-strategy` skill → Automation scope

Related Skills

web-design-guidelines

16
from diegosouzapw/awesome-omni-skill

Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".

vibe-techdesign

16
from diegosouzapw/awesome-omni-skill

Create a Technical Design Document for your MVP. Use when the user wants to plan architecture, choose tech stack, or says "plan technical design", "choose tech stack", or "how should I build this".

ui-ux-designer

16
from diegosouzapw/awesome-omni-skill

Create interface designs, wireframes, and design systems. Masters user research, accessibility standards, and modern design tools.

ui-ux-design-system

16
from diegosouzapw/awesome-omni-skill

Expert in building premium, accessible UI/UX design systems for SaaS apps. Covers design tokens, component architecture with shadcn/ui and Radix, dark mode, glassmorphism, micro-animations, responsive layouts, and accessibility. Use when: ui, ux, design system, shadcn, radix, tailwind, dark mode, animation, accessibility, components, figma to code.

ui-designer

16
from diegosouzapw/awesome-omni-skill

Generate and serve live HTML/CSS/JS UI designs from natural language prompts. Use when the user asks to design, create, build, or prototype a website, landing page, UI, dashboard, web page, or frontend mockup. Also triggers on requests to update, tweak, or iterate on a previously generated design. Replaces traditional UI design + frontend dev workflow.

ui-design

16
from diegosouzapw/awesome-omni-skill

Applies consistent renderer UI/UX implementation patterns using a Vercel-inspired white theme, strong accessibility defaults, and repository component conventions.

ui-design-styles

16
from diegosouzapw/awesome-omni-skill

Comprehensive guidance for applying modern UI design styles, including Soft UI, Dark Mode, Flat Design, Neumorphism, Glassmorphism, and Aurora UI Gradients. Use when a user asks to: (1) Apply a specific UI style to a project, (2) Create a modern, visually appealing UI prototype, (3) Improve accessibility while following design trends, or (4) Understand the technical implementation of specific UI effects like frosted glass or soft shadows.

ui-design-create-component

16
from diegosouzapw/awesome-omni-skill

Guided component creation with proper patterns Use when: the user asks to run the `create-component` workflow and the task requires multi-step orchestration. Do not use when: the task is small, single-step, and can be completed directly without orchestration overhead.

ui-design-a11y

16
from diegosouzapw/awesome-omni-skill

无障碍设计审查与修复能力。

u04425-experiment-design-for-nutrition-and-meal-planning

16
from diegosouzapw/awesome-omni-skill

Operate the "Experiment design for nutrition and meal planning" capability in production for nutrition and meal planning workflows. Use when mission execution explicitly requires this capability and outcomes must be reproducible, policy-gated, and handoff-ready.

u2615-regression-sentinel-design-for-household-logistics

16
from diegosouzapw/awesome-omni-skill

Operate the "regression sentinel design for household logistics" capability in production for regression sentinel design for household logistics workflows. Use when mission execution explicitly requires this capability and outcomes must be reproducible, policy-gated, and handoff-ready.

tool-design-style-selector

16
from diegosouzapw/awesome-omni-skill

Use when you need to define or converge a project's visual direction. Scan project documentation to identify intent, then produce a design-system.md (either preserve existing style or pick from 30 presets). Triggers: design system, design spec, UI style, visual style, design tokens, color palette, typography, layout. Flow: scan → intent → (gate) preserve vs preset → deploy design-system.md after confirmation → (default) implement UI/UX per design-system.md (plan first, then execute).