docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
---
|
||||
id: wiki-2026-0508-test-automation
|
||||
title: Test Automation
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [automated testing, test automation pyramid, CI testing]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.95
|
||||
verification_status: applied
|
||||
tags: [testing, automation, ci-cd, qa, devops]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: typescript
|
||||
framework: vitest-playwright-msw-pact
|
||||
---
|
||||
|
||||
# Test Automation
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 confidence 의 deploy 의 — 매 tests 의 paying 의"**. Test automation 의 unit / integration / e2e / contract / performance 의 의 CI 의 의 mechanically running 의 의 — 매 regression 의 catch, 매 deploy velocity 의 unlock. 2026 의 stack: Vitest (unit), Playwright (e2e), MSW (API mock), Pact (contract), k6 (load).
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 testing pyramid (modern)
|
||||
- **Unit** (60-70%): 매 fast (<100ms each), 매 isolated, 매 logic 의.
|
||||
- **Integration** (20-30%): 매 real DB / Redis 의 (testcontainers), 매 module boundaries.
|
||||
- **Component** (10%): 매 React/Vue 의 isolated rendering.
|
||||
- **E2E** (5-10%): 매 Playwright, 매 critical user journeys 의 only.
|
||||
- **Contract**: producer/consumer 의 — 매 microservices.
|
||||
|
||||
### 매 매 modern paradigms
|
||||
- **TDD** still relevant for libraries / domain logic.
|
||||
- **Snapshot testing** judiciously — 매 churn explosion 위험.
|
||||
- **Property-based** (fast-check, hypothesis) — 매 invariants.
|
||||
- **Visual regression** (Chromatic, Percy, Playwright trace).
|
||||
|
||||
### 매 응용
|
||||
1. PR-blocking unit + critical e2e.
|
||||
2. Pre-merge contract tests (Pact broker).
|
||||
3. Nightly load test + regression budget.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Vitest unit test
|
||||
```typescript
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { calcTax } from './tax';
|
||||
|
||||
describe('calcTax', () => {
|
||||
it.each([
|
||||
[100, 'CA', 8.25],
|
||||
[100, 'OR', 0],
|
||||
])('%i in %s = %f', (amt, state, expected) => {
|
||||
expect(calcTax(amt, state)).toBe(expected);
|
||||
});
|
||||
it('rejects negative', () => {
|
||||
expect(() => calcTax(-1, 'CA')).toThrow(/non-negative/);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### MSW — API mocking
|
||||
```typescript
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
|
||||
export const server = setupServer(
|
||||
http.get('/api/users/:id', ({ params }) =>
|
||||
HttpResponse.json({ id: params.id, name: 'Alice' })),
|
||||
);
|
||||
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
```
|
||||
|
||||
### Playwright e2e (critical path)
|
||||
```typescript
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('checkout flow', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /add to cart/i }).first().click();
|
||||
await page.getByRole('link', { name: /cart/i }).click();
|
||||
await page.getByRole('button', { name: /checkout/i }).click();
|
||||
await page.getByLabel(/email/i).fill('test@example.com');
|
||||
await page.getByLabel(/card number/i).fill('4242424242424242');
|
||||
await page.getByRole('button', { name: /pay/i }).click();
|
||||
await expect(page.getByRole('heading', { name: /thank you/i })).toBeVisible();
|
||||
});
|
||||
```
|
||||
|
||||
### Testcontainers (real Postgres in CI)
|
||||
```typescript
|
||||
import { PostgreSqlContainer } from '@testcontainers/postgresql';
|
||||
let container: any, db: any;
|
||||
beforeAll(async () => {
|
||||
container = await new PostgreSqlContainer('postgres:16').start();
|
||||
db = drizzle(postgres(container.getConnectionUri()));
|
||||
await migrate(db, { migrationsFolder: './drizzle' });
|
||||
}, 60_000);
|
||||
afterAll(async () => container.stop());
|
||||
```
|
||||
|
||||
### Pact contract test (consumer)
|
||||
```typescript
|
||||
import { PactV3, MatchersV3 } from '@pact-foundation/pact';
|
||||
const provider = new PactV3({ consumer: 'web', provider: 'api' });
|
||||
provider.given('user 1 exists').uponReceiving('a request for user 1')
|
||||
.withRequest({ method: 'GET', path: '/users/1' })
|
||||
.willRespondWith({ status: 200, body: MatchersV3.like({ id: 1, name: 'Alice' }) });
|
||||
await provider.executeTest(async (mock) => {
|
||||
const r = await fetch(`${mock.url}/users/1`);
|
||||
expect((await r.json()).name).toBe('Alice');
|
||||
});
|
||||
```
|
||||
|
||||
### Property-based (fast-check)
|
||||
```typescript
|
||||
import fc from 'fast-check';
|
||||
test('reverse twice = identity', () => {
|
||||
fc.assert(fc.property(fc.array(fc.integer()), (arr) => {
|
||||
expect([...arr].reverse().reverse()).toEqual(arr);
|
||||
}));
|
||||
});
|
||||
```
|
||||
|
||||
### Flaky-test quarantine (Playwright)
|
||||
```typescript
|
||||
test.describe.configure({ retries: 2 });
|
||||
test('flaky-known @quarantine', async ({ page }) => { /* ... */ });
|
||||
// CI: skip @quarantine on PR, run nightly only
|
||||
```
|
||||
|
||||
### k6 load test
|
||||
```javascript
|
||||
import http from 'k6/http';
|
||||
import { check } from 'k6';
|
||||
export const options = {
|
||||
stages: [{ duration: '2m', target: 100 }, { duration: '5m', target: 100 }],
|
||||
thresholds: { http_req_duration: ['p(99)<500'] },
|
||||
};
|
||||
export default () => {
|
||||
const r = http.get('https://staging.app/api/items');
|
||||
check(r, { '200': (x) => x.status === 200 });
|
||||
};
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Layer |
|
||||
|---|---|
|
||||
| pure function / domain logic | unit (Vitest) |
|
||||
| DB query / SQL correctness | integration (testcontainers) |
|
||||
| critical revenue path | e2e (Playwright) |
|
||||
| microservice API stability | contract (Pact) |
|
||||
| invariant property | property-based (fast-check) |
|
||||
|
||||
**기본값**: 60/30/10 unit/integration/e2e split, MSW for external APIs, testcontainers for DB, Pact for service boundaries.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Software Quality]]
|
||||
- 변형: [[TDD]] · [[BDD]] · [[Property-based Testing]]
|
||||
- 응용: [[Continuous Integration]] · [[Visual Regression]]
|
||||
- Adjacent: [[Playwright]] · [[Pact]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: test scaffolding from impl, edge-case enumeration, flaky root-cause analysis from trace.zip, snapshot diff explanation.
|
||||
**언제 X**: auto-generated tests 의 review 없이 의 merge — 매 tautological tests (mock returns x → assert x).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Ice-cream cone** (e2e-heavy, unit-light): 매 slow CI, 매 flaky.
|
||||
- **Mocking what you don't own** (deep mocks of fetch): 매 mock drift.
|
||||
- **Snapshot of everything**: 매 PR diff 의 noise.
|
||||
- **Shared mutable state in tests**: 매 order-dependent flaky.
|
||||
- **No quarantine**: 매 1 flaky 의 CI 의 distrust.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Vitest docs, Playwright docs, MSW v2, Pact docs, k6 docs, Kent Beck TDD).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — pyramid + Vitest/Playwright/MSW/Pact patterns |
|
||||
Reference in New Issue
Block a user