Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

test-doubles

/test-doubles

Pomaga świadomie dobierać stuby, fejki i mocki oraz domyślnie weryfikować stan zamiast interakcji, by testy przetrwały refaktoryzację, gdy test zastępuje wolną, zewnętrzną lub niedeterministyczną zależność.

Repozytorium
AI-SKILLS ↗
Licencja
MIT
Ostatnia zmiana repozytorium
05.09.2026

Ocena i bezpieczeństwo

90/ 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ść25 / 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
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 05.09.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

Pomaga świadomie dobierać stuby, fejki i mocki oraz domyślnie weryfikować stan zamiast interakcji, by testy przetrwały refaktoryzację, gdy test zastępuje wolną, zewnętrzną lub niedeterministyczną zależność.

Oryginalny opis (EN)

Choose stubs, fakes, and mocks deliberately and default to verifying state over interaction so tests survive refactors. Use when a test needs to stand in for a slow, external, or nondeterministic dependency.

Jak działa

  1. Method
  2. Checks
  3. Boundaries
Sekcje z nagłówków SKILL.md, w oryginale · 51 linii, 421 słów
Podgląd SKILL.md
---
name: test-doubles
description: Choose stubs, fakes, and mocks deliberately and default to verifying state over interaction so tests survive refactors. Use when a test needs to stand in for a slow, external, or nondeterministic dependency.
---

# Test doubles

A test double replaces a real dependency the test cannot afford: a payment
gateway, a system clock, a database round trip. The trap is reaching for a
mock by reflex and asserting that a method was called, which pins the code's
internal wiring rather than its result. Such tests fail on every refactor that
keeps behavior intact, and they pass while behavior is quietly broken. Pick
the double that matches what you actually need to control.

## Method

1. **Name the double you mean.** A stub returns canned answers, a fake is a
   working lightweight implementation such as an in-memory repository, a mock
   records calls for later verification, a spy wraps a real object to observe
   it. Loose talk of "mock everything" hides which of these the test needs.
2. **Default to state verification.** Drive the system through the double,
   then assert on the returned value or resulting state:
   `assert account.balance == 40`. This survives any refactor that preserves
   the outcome, which is the entire reason the test exists.
3. **Reserve mocks for interaction that is the behavior.** Verify a call only
   when the call is itself the observable effect: an email was sent, an event
   was published, a card was charged. `verify(gateway).charge(500)` is right
   when charging is what the code exists to do.
4. **Prefer a fake to a pile of stubs.** For a repository or clock, one small
   in-memory fake reused across tests reads cleaner than restubbing each
   method per test, and it catches sequencing bugs a lone stub cannot.
5. **Only double what you own or what hurts.** Wrap a third-party SDK behind
   your own interface and fake that, instead of mocking the vendor's types.
   Doubling a type you do not control freezes assumptions the next version
   breaks.
6. **Keep doubles honest with a contract test.** A fake that drifts from the
   real dependency yields false green. Run one shared suite against both the
   fake and the real implementation so their behavior stays aligned.

## Checks

- If you renamed a private method without changing behavior, would this test
  still pass?
- Does each mock verification match an effect a user or another system can
  observe?
- Do several doubles in one test signal a unit with too many collaborators to
  isolate cleanly?

## Boundaries

This is about choosing and placing doubles, not about seam design or the
real-dependency end of the scale: defer wiring seams to integration-testing
and library choice to the project. Mocking frameworks vary, so follow the one
already in the suite.

Wersje

W bazie nie ma innych skilli o nazwie test-doubles.

Migawka bazy z 13.11.2026 · wersja paczki ab20b44480bc (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

  • 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.
  • 100rspec-mocking
    Opisuje mockowanie w RSpec: doubles, stuby, mocki, spye i strategie częściowego mockowania.
  • 100mock-stubs-spies-test-doubles
    Izoluje testowane elementy od sieci, systemu plików i zewnętrznych zależności, używając odpowiednich atrap testowych.
  • 100test-doubles-design
    Pomaga projektować i recenzować test doubles: taksonomia dummy, stub, spy, fake i mock wg Meszarosa, weryfikacja stanu i interakcji oraz koszt dublerów.
  • 90mock-recon
    Audytuje istniejące mocki i test doubles, wskazując dryf kontraktów, brakujące przypadki błędów i nieaktualne fixtures.

Uwagi i zgłoszenia

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