Main Site โ†—

test-design

by rsmdt24018GitHub

This skill provides concrete testing methodology with pyramid distribution guidelines, framework-specific patterns, and anti-pattern examples. It covers Jest and Pytest with practical code samples for unit, integration, and E2E testing strategies.

Unlock Deep Analysis

Use AI to visualize the workflow and generate a realistic output preview for this skill.

Powered by Fastest LLM

Target Audience

Developers implementing test suites, code reviewers assessing test quality, and engineering leads establishing testing standards

8/10Security

Low security risk, safe to use

9
Clarity
9
Practicality
8
Quality
8
Maintainability
7
Innovation
Testing
test-pyramidjest-pytesttest-patternscode-quality
Compatible Agents
Claude Code
Claude Code
~/.claude/skills/
Codex CLI
Codex CLI
~/.codex/skills/
Gemini CLI
Gemini CLI
~/.gemini/skills/
O
OpenCode
~/.opencode/skills/
O
OpenClaw
~/.openclaw/skills/
GitHub Copilot
GitHub Copilot
~/.copilot/skills/
Cursor
Cursor
~/.cursor/skills/
W
Windsurf
~/.codeium/windsurf/skills/
C
Cline
~/.cline/skills/
R
Roo Code
~/.roo/skills/
K
Kiro
~/.kiro/skills/
J
Junie
~/.junie/skills/
A
Augment Code
~/.augment/skills/
W
Warp
~/.warp/skills/
G
Goose
~/.config/goose/skills/
SKILL.md

Test Design Skill

A structured approach to designing tests that give confidence without excessive maintenance burden.

Core Philosophy

Test behavior, not implementation. Tests that couple to internal implementation details become fragile and refactor-resistant. Aim to test what the code does, not how it does it.

The best test is the one that fails when something breaks, and passes when everything works. Perfect coverage means nothing if tests don't catch real bugs.

Testing Pyramid

        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚   E2E   โ”‚  โ† Few, slow, high confidence
       โ”Œโ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”
       โ”‚ Integrationโ”‚ โ† Some, medium speed
      โ”Œโ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”
      โ”‚    Unit     โ”‚ โ† Many, fast, granular
      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Unit tests form the base โ€” fast, isolated, cover individual functions. Integration tests verify components work together. E2E tests validate complete user journeys.

Test Case Design

Arrange-Act-Assert (AAA) Pattern

def test_withdraw_amount_exceeds_balance():
    # Arrange
    account = Account(balance=Decimal("100.00"))
    
    # Act
    result = account.withdraw(Decimal("150.00"))
    
    # Assert
    assert result.is_failed()
    assert account.balance == Decimal("100.00")  # unchanged

Given-When-Then (GWT) Pattern

Feature: Account Withdrawal

  Scenario: Withdrawal amount exceeds balance
    Given an account with balance $100
    When I withdraw $150
    Then the withdrawal is rejected
    And the balance remains $100

Test Categories

๐Ÿ”ด Happy Path Tests

  • Verify the main success scenario works
  • At least one per feature/function

๐ŸŸก Edge Case Tests

  • Boundary values (0, -1, max integer)
  • Empty/null inputs
  • Rare but possible conditions

๐ŸŸก Error Case Tests

  • Invalid inputs
  • Missing dependencies
  • Permission denied scenarios

๐ŸŸข Edge/Extreme Cases

  • Very large inputs
  • Very small inputs
  • Unicode/special characters
  • Concurrent access

Test Doubles (Mocks/Stubs/Fakes)

TypePurposeUse When
DummyFill parameter listsNever actually used
StubProvide predetermined responsesTest requires specific data
SpyRecord how something was calledVerify interactions
MockPre-programmed expectationsVerify behavior + interactions
FakeWorking implementation (simplified)Real impl too slow/complex

Rule: Prefer real objects over mocks when practical. Mocks hide integration problems.

Test Naming Convention

test_<unit>_<scenario>_<expected_result>

Examples:

  • test_user_create_with_valid_input_succeeds
  • test_user_create_with_duplicate_email_fails
  • test_order_cancel_after_shipment_refunds_full_amount

Coverage Targets

LayerTargetPurpose
Unit70-80%Core business logic
Integration40-60%Key flows work together
E2ECritical paths onlyUser journeys

Note: Coverage is a guide, not a goal. 100% coverage with shallow tests is worse than 70% with meaningful assertions.

Test Execution

Unit Tests

Run frequently during development (every save).

# Go
go test ./...

# Python
pytest tests/unit/ -v

# TypeScript
npm test -- --coverage

Integration Tests

Run before PR, after unit tests pass.

# Start dependencies
docker-compose up -d

# Run integration suite
pytest tests/integration/ -v

E2E Tests

Run on CI against deployed environment.

# CI/CD pipeline
npm run test:e2e -- --specs=critical-paths

Test Data Management

Strategies

  1. Factories/Fixtures โ€” Create test data on demand
  2. Seeded Data โ€” Deterministic test datasets
  3. Randomized Data โ€” Fuzz testing with random inputs
  4. Snapshot Testing โ€” Verify serializable outputs

Best Practices

  • Tests should be independent (no shared state)
  • Each test should clean up after itself
  • Use meaningful data, not magic values
  • Avoid test interdependencies

File Structure

test-design/
โ”œโ”€โ”€ SKILL.md
โ””โ”€โ”€ references/
    โ”œโ”€โ”€ test-case-templates.md
    โ”œโ”€โ”€ testing-pyramid.md
    โ”œโ”€โ”€ mocking-strategies.md
    โ”œโ”€โ”€ test-naming-conventions.md
    โ””โ”€โ”€ per-type/
        โ”œโ”€โ”€ unit-test-guide.md
        โ”œโ”€โ”€ integration-test-guide.md
        โ””โ”€โ”€ e2e-test-guide.md

Source: https://github.com/rsmdt/the-startup#plugins~team~skills~development~test-design

Content curated from original sources, copyright belongs to authors

Grade A
8.4AI Score
Best Practices
Checking...
Try this Skill

User Rating

USER RATING

0UP
0DOWN
Loading files...

WORKS WITH

Claude Code
Claude
Codex CLI
Codex
Gemini CLI
Gemini
O
OpenCode
O
OpenClaw
GitHub Copilot
Copilot
Cursor
Cursor
W
Windsurf
C
Cline
R
Roo
K
Kiro
J
Junie
A
Augment
W
Warp
G
Goose