Przejdź do treści
Biblioteka skilli
Programowanie · Nauka i wyjaśnianie

test-design

/test-design

Opisuje dobre projektowanie testów: testy behawioralne, poziomy testów, atrapy, testy E2E i antywzorce, z wyborem między stubami a mockami.

Licencja
MIT
Ostatnia zmiana repozytorium
04.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
5
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 04.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Opisuje dobre projektowanie testów: testy behawioralne, poziomy testów, atrapy, testy E2E i antywzorce, z wyborem między stubami a mockami.

Oryginalny opis (EN)

Authoritative resource on writing great tests: behavior-focused test design, test levels, test doubles, sociable testing, integration testing, E2E/browser testing, test data factories, and anti-patterns. Use when designing test strategies, choosing test levels, writing resilient tests, selecting dummies/stubs/fakes/spies/mocks, avoiding mock-heavy brittleness, or reviewing test quality.

Jak działa

  1. Purpose
  2. Relationship to structured development
  3. When to use
  4. Core Principles
  5. Authoritative Test Data
  6. Domain Language
  7. Test Level Heuristic
  8. Reference Files
Sekcje z nagłówków SKILL.md, w oryginale · 94 linii, 1 124 słów
Podgląd SKILL.md
---
name: test-design
description: >-
  Authoritative resource on writing great tests: behavior-focused test design,
  test levels, test doubles, sociable testing, integration testing, E2E/browser
  testing, test data factories, and anti-patterns. Use when designing test
  strategies, choosing test levels, writing resilient tests, selecting
  dummies/stubs/fakes/spies/mocks, avoiding mock-heavy brittleness, or reviewing
  test quality.
license: MIT
metadata:
  author: itzcull
---

## Purpose

Provide an authoritative resource on writing great tests, grounded in the principle that tests encode intent, not implementation. This skill helps agents choose appropriate test levels, write behavior-focused tests, use test doubles deliberately, prefer real collaborators where practical, and avoid brittle tests that fail during safe refactoring.

## Relationship to structured development

Within [structured development](../structured-development/SKILL.md), this skill supplies verification design when [preparing increments](../structured-development/SKILL.md#3-select-and-prepare-the-next-increment) and [evaluating results](../structured-development/SKILL.md#5-evaluate-the-result). It helps decide what evidence is needed and how to obtain it; [test-driven-development](../test-driven-development/SKILL.md) separately owns test-first sequencing when that protocol is selected.

Start from the intended observable behavior, acceptance criteria, relevant risks, public interfaces, and dependency boundaries. Explain why the chosen test level and interface can demonstrate the promised behavior. Return the test strategy, tests, or test-quality findings requested, with coverage limits; when tests are executed, distinguish observed results from checks only proposed.

Test design does not authorize changing acceptance criteria to fit convenient assertions. Return ambiguous expected outcomes and untestable obligations to the enclosing procedure for a decision. Passing the selected tests provides bounded evidence, not automatic feature acceptance or proof that every relevant concern is covered.

## When to use

- Designing a testing strategy for a feature or system
- Choosing between unit, integration, component, and E2E tests
- Writing behavior-focused tests through public APIs
- Deciding whether to use dummies, stubs, fakes, spies, mocks, or real collaborators
- Separating functional core logic from imperative shell effects to reduce mocking needs
- Setting up integration tests for databases, APIs, queues, or filesystems
- Preventing fake drift or mock drift across adapter and service boundaries
- Testing React components or browser flows with Testing Library or Playwright
- Reviewing tests for brittleness, implementation coupling, or missing coverage
- Creating test data factories and schema-validated test fixtures

## Core Principles

- Tests are executable specifications of observable behavior
- A test should fail if and only if the code no longer does what it promises
- Test the unit of behavior, not the unit of code
- Test through public APIs; internals should be invisible to tests
- Prefer sociable tests with real in-process collaborators; use solitary tests when a boundary is awkward, slow, non-deterministic, or still being designed
- Use test doubles at architectural boundaries, not between internal collaborators inside the same behavioral unit
- Do not double what you do not own directly; define your own role or port, double that role in unit tests, and prove adapters with integration or contract tests
- Prefer state and outcome verification over interaction verification when possible
- Use interaction verification only when the outgoing interaction is the observable behavior or when outside-in design is discovering a role
- Avoid header interfaces that merely mirror concrete classes for mockability; interfaces should express roles owned by the application
- Prefer pure functional cores and thin imperative shells: pure domain logic should need no mocks, while shell behavior is proven with sparse integration tests
- Organize tests by behavior rather than mirroring implementation files
- Test data factories should return complete objects with sensible defaults and optional overrides
- Validate factory output against real schemas when schemas exist

## Authoritative Test Data

Tests should rely on the same application-owned definitions as production code. Import real schemas, types, domain constructors, and existing test data factories from their authoritative locations instead of redefining parallel shapes inside test files.

Use test-only factories when application factories do not exist, but keep them aligned with real application contracts:

- Build complete, valid objects by default
- Accept focused overrides for the behavior under test
- Compose existing factories for nested or related data
- Validate generated data with real schemas when schemas exist
- Avoid duplicating domain constraints in test helpers

Minimize shared mutable state in tests. Prefer creating fresh data inside each test through factories over mutating outer-scope variables or relying on setup hooks that hide important preconditions. Shared setup is acceptable only when it represents expensive infrastructure or stable test harness configuration, not behavior-specific data.

## Domain Language

Use these terms precisely when designing, writing, or reviewing tests:

| Term | Role in test design |
| --- | --- |
| `Test double` | Any replacement collaborator used in a test instead of the real object |
| `Dummy` | A value passed only to satisfy a signature; the test does not exercise it |
| `Stub` | Controls indirect inputs by returning specific values or throwing specific exceptions |
| `Fake` | Lightweight working implementation that behaves like the real collaborator but omits production qualities such as persistence, scale, or stability |
| `Spy` | Records indirect outputs from the system under test so the assert phase can query calls and arguments |
| `Mock` | Strict expectation-based double configured before the act phase; it can fail the test itself when expected role interactions are violated |
| `Temporary stub` | Short-lived scaffold used in outside-in TDD before the real collaborator exists; remove it once the production implementation is available |

Prefer role-first language over tool-specific labels. For example, say "use a Jest mock function to stub this response" or "use a mock function to spy on this interaction" when the library primitive is doing stub or spy work. Reserve `mock` for strict pre-declared interaction expectations.

The key design question is not "what object did the test framework create?" It is "what role does this double play in the test's behavior specification?"

Mocks are not general-purpose isolation tools. In their original design role, mocks discover or enforce application-owned collaboration protocols: "this object tells that role to do this." If a mock only exists so a concrete class can be isolated, it may be introducing test-induced design damage.

## Test Level Heuristic

| Question | Preferred Test Level |
| --- | --- |
| Does a behavioral rule still hold inside our system? | Unit test |
| Does our adapter honor a dependency contract? | Integration test |
| Does a service still satisfy a consumer-provider protocol? | Contract test |
| Does a UI component behave the way a user experiences it? | Component/browser test |
| Does the whole system complete a critical user journey? | E2E test |

## Reference Files

- [Testing Guidelines](references/testing-guidelines.md) - Core principles, test levels, test double philosophy, test data patterns, coverage guidance, React testing, and anti-patterns
- [Test Doubles](references/test-doubles.md) - Dummy, fake, stub, spy, mock, and temporary stub taxonomy; mock roles; functional core; contract testing; sociable vs solitary tests
- [Integration Testing](references/integration-testing.md) - Adapter testing, Testcontainers, database testing, MSW, consumer-driven contract testing, message queues, filesystem tests, and environment safety
- [E2E and Browser Testing](references/e2e-testing.md) - Testing Library query priority, Playwright locators/assertions, userEvent patterns, E2E structure, CI, debugging, and accessibility testing
Pliki w paczce (5)
  • SKILL.md 8 KB
  • references/e2e-testing.md 17 KB
  • references/integration-testing.md 18 KB
  • references/test-doubles.md 26 KB
  • references/testing-guidelines.md 18 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · itzcull/software-skills100MIT
mhmdelgazzar/agentex100MIT
bdfinst/agentic-dev-team100MIT
brrritscold/compainy100MIT
app-vitals/shipwright90MIT
tadokoro-ryusuke/cc-plugins90MIT
yasunori0418/skills90MIT
nahid-sparktales/agent-dispatcher90MIT

Migawka bazy z 13.11.2026 · wersja paczki fcb4d5f2d27b (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100swift-testing
    Pisze testy w Swift Testing z @Test i expect, migruje testy z XCTest oraz przygotowuje atrapy, fikstury i testy migawkowe.
  • 100generating-test-doubles
    Generuje mocki, stuby, spye i fake'i do izolacji zależności w testach.
  • 100generating-test-doubles
    Generuje mocki, stuby, spye i fake'i do izolacji zależności w testach.
  • 100mock-audit
    Sprawdza testy z mockami, ujawnia testy, które mockują testowaną jednostkę lub sprawdzają tylko wywołania, i zamienia je na prawdziwe zależności.
  • 100testing
    Opisuje niezależne od stosu zasady testowania: strategia testów, piramida, test doubles, izolacja, niestabilne testy i antywzorce, przy projektowaniu strategii lub przeglądzie jakości testów.
  • 100test-patterns
    Stosuje sprawdzone wzorce testowe: Arrange-Act-Assert, Given-When-Then, Test Data Builders, Object Mother, testy parametryzowane, fixtures, spies i test doubles, by testy były czytelne i niezawodne.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.