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

testing-patterns

/testing-patterns

Opisuje piramidę testów, mockowanie, fixtures i organizację testów, pomocne przy wyborze tego, co mockować.

Repozytorium
cardume ↗
Licencja
MIT
Ostatnia zmiana repozytorium
04.11.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
2
Skrypty
1
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

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

Licencja

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

Co sprawdzić przed instalacją
  • 1 skrypt w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.

Skrypty: scripts/test_runner.py

Co robi i kiedy

Opisuje piramidę testów, mockowanie, fixtures i organizację testów, pomocne przy wyborze tego, co mockować.

Oryginalny opis (EN)

Test pyramid, mocking, fixtures and test organization. Use when designing tests, choosing what to mock or reviewing test quality.

Jak działa

  1. 1. Testing Pyramid
  2. 2. AAA Pattern
  3. 3. Test Type Selection
  4. 4. Unit Test Principles
  5. 5. Integration Test Principles
  6. 6. Mocking Principles
  7. 7. Test Organization
  8. 8. Test Data
  9. 9. Best Practices
  10. 10. Anti-Patterns
Sekcje z nagłówków SKILL.md, w oryginale · 174 linii, 592 słów
Podgląd SKILL.md
---
name: testing-patterns
description: "Test pyramid, mocking, fixtures and test organization. Use when designing tests, choosing what to mock or reviewing test quality."
allowed-tools: Read Write Edit Glob Grep Bash
---

# Testing Patterns

> Principles for reliable test suites.

---

## 1. Testing Pyramid

```
        /\          E2E (Few)
       /  \         Critical flows
      /----\
     /      \       Integration (Some)
    /--------\      API, DB queries
   /          \
  /------------\    Unit (Many)
                    Functions, classes
```

---

## 2. AAA Pattern

| Step | Purpose |
|------|---------|
| **Arrange** | Set up test data |
| **Act** | Execute code under test |
| **Assert** | Verify outcome |

---

## 3. Test Type Selection

### When to Use Each

| Type | Best For | Speed |
|------|----------|-------|
| **Unit** | Pure functions, logic | Fast (<50ms) |
| **Integration** | API, DB, services | Medium |
| **E2E** | Critical user flows | Slow |

---

## 4. Unit Test Principles

### Good Unit Tests

| Principle | Meaning |
|-----------|---------|
| Fast | < 100ms each |
| Isolated | No external deps |
| Repeatable | Same result always |
| Self-checking | No manual verification |
| Timely | Written with code |

### What to Unit Test

| Test | Don't Test |
|------|------------|
| Business logic | Framework code |
| Edge cases | Third-party libs |
| Error handling | Simple getters |

---

## 5. Integration Test Principles

### What to Test

| Area | Focus |
|------|-------|
| API endpoints | Request/response |
| Database | Queries, transactions |
| External services | Contracts |

### Setup/Teardown

| Phase | Action |
|-------|--------|
| Before All | Connect resources |
| Before Each | Reset state |
| After Each | Clean up |
| After All | Disconnect |

---

## 6. Mocking Principles

### When to Mock

| Mock | Don't Mock |
|------|------------|
| External APIs | The code under test |
| Database (unit) | Simple dependencies |
| Time/random | Pure functions |
| Network | In-memory stores |

### Mock Types

| Type | Use |
|------|-----|
| Stub | Return fixed values |
| Spy | Track calls |
| Mock | Set expectations |
| Fake | Simplified implementation |

---

## 7. Test Organization

### Naming

| Pattern | Example |
|---------|---------|
| Should behavior | "should return error when..." |
| When condition | "when user not found..." |
| Given-when-then | "given X, when Y, then Z" |

### Grouping

| Level | Use |
|-------|-----|
| describe | Group related tests |
| it/test | Individual case |
| beforeEach | Common setup |

---

## 8. Test Data

### Strategies

| Approach | Use |
|----------|-----|
| Factories | Generate test data |
| Fixtures | Predefined datasets |
| Builders | Fluent object creation |

### Principles

- Use realistic data
- Randomize non-essential values (faker)
- Share common fixtures
- Keep data minimal

---

## 9. Best Practices

| Practice | Why |
|----------|-----|
| One assert per test | Clear failure reason |
| Independent tests | No order dependency |
| Fast tests | Run frequently |
| Descriptive names | Self-documenting |
| Clean up | Avoid side effects |

---

## 10. Anti-Patterns

| ❌ Don't | ✅ Do |
|----------|-------|
| Test implementation | Test behavior |
| Duplicate test code | Use factories |
| Complex test setup | Simplify or split |
| Ignore flaky tests | Fix root cause |
| Skip cleanup | Reset state |

---

> **Remember:** Tests are documentation. If someone can't understand what the code does from the tests, rewrite them.
Pliki w paczce (2)
  • SKILL.md 3 KB
  • scripts/test_runner.py 7 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · jeffersonvalente/cardume100MIT
Reprograme/redevkit100MIT
piomin/claude-ai-spring-boot100Apache-2.0
FrancoStino/opencode-skills-collection100MIT
rootcastleco/rei-skills100MIT
davila7/claude-code-templates100MIT
svngoku/coding-agents-skills100MIT
organvm-iv-taxis/a-i--skills100Apache-2.0
leather-io/mono100MIT

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

  • 100python-testing-patterns
    Wyjaśnia wzorce pytest i strategie testowania w Python: fixtures, mockowanie i organizacja testów.
  • 100eng-testing
    Prowadzi przy pisaniu testów, projektowaniu strategii testów i przeglądzie pokrycia: piramidę testów, nazewnictwo, mockowanie i politykę testów niestabilnych.
  • 95pact-testing-strategies
    Doradza strategie testów w fazie PACT Test, czyli piramidę testów, testy jednostkowe, integracyjne i E2E oraz pokrycie kodu.
  • 80alpha-core:testing-patterns
    Układa strategię testów: piramidę testów, TDD i BDD, mockowanie, dane testowe, testy migawkowe i mutacyjne.
  • 100testing-strategy
    Opisuje metodykę testów: piramidę, deterministyczne testy jednostkowe i integracyjne oraz diagnozę niestabilnych testów.
  • 100testing-strategies
    Dobiera strukturę testów: piramidę, AAA, test doubles, fixtures, asercje i cele pokrycia, w dowolnym języku.

Uwagi i zgłoszenia

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