Files
2nd/10_Wiki/Topic_Programming/Architecture/Test Automation Pyramid.md
T
Antigravity Agent 9148c358d0 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 폴더 제거.
2026-07-05 00:33:48 +09:00

5.3 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-test-automation-pyramid Test Automation Pyramid 10_Wiki/Topics verified self
Test Pyramid
테스트 피라미드
Cohn Pyramid
none A 0.92 applied
testing
architecture
pyramid
automation
2026-05-10 pending
language framework
TypeScript Vitest/Playwright

Test Automation Pyramid

매 한 줄

"매 unit test 가 base, e2e 가 tip". Mike Cohn 의 2009 Succeeding with Agile 에서 origin — slow/expensive UI test 의 over-reliance 의 anti-pattern. 매 2026 modern stack 은 unit + integration + contract + e2e 의 4-layer 의 evolution.

매 핵심

매 layers (bottom-up)

  • Unit (70%): pure function, 단일 class, <10ms, in-memory.
  • Integration (20%): DB, HTTP client, 매 real adapter, 100ms-1s.
  • Contract (5-10%): provider/consumer 매 Pact / OpenAPI schema.
  • E2E (5%): 매 full user journey, Playwright/Cypress, 10s+.

매 anti-shapes

  • Ice cream cone: 매 e2e heavy, unit 부족 — slow CI, flaky.
  • Hourglass: 매 unit + e2e 만, integration 의 gap — production bug 의 source.
  • Cupcake: manual test layer 의 추가 — automation 의 의미 상실.

매 응용

  1. CI pipeline tier — unit on every commit, e2e on merge to main.
  2. Bug 발견 시 lowest-level test 의 추가 (root cause level).
  3. Test budget 분배 결정 (시간 / 신뢰도 trade-off).

💻 패턴

Vitest unit test

import { describe, it, expect } from 'vitest';
import { calculateDiscount } from './pricing';

describe('calculateDiscount', () => {
  it('applies 10% for VIP customer', () => {
    expect(calculateDiscount(100, 'VIP')).toBe(90);
  });

  it('returns full price for standard customer', () => {
    expect(calculateDiscount(100, 'STANDARD')).toBe(100);
  });
});

Integration test (real Postgres via testcontainers)

import { PostgreSqlContainer } from '@testcontainers/postgresql';

let container: StartedTestContainer;
beforeAll(async () => {
  container = await new PostgreSqlContainer('postgres:16').start();
  process.env.DATABASE_URL = container.getConnectionUri();
});

it('persists user', async () => {
  const repo = new UserRepository();
  await repo.save({ id: '1', name: 'Alice' });
  const found = await repo.findById('1');
  expect(found?.name).toBe('Alice');
});

Contract test (Pact consumer)

import { PactV3, MatchersV3 } from '@pact-foundation/pact';

const provider = new PactV3({ consumer: 'web', provider: 'api' });

provider
  .uponReceiving('a request for user')
  .withRequest({ method: 'GET', path: '/users/1' })
  .willRespondWith({
    status: 200,
    body: { id: MatchersV3.string('1'), name: MatchersV3.string('Alice') }
  });

Playwright E2E

import { test, expect } from '@playwright/test';

test('user can checkout', async ({ page }) => {
  await page.goto('/products/42');
  await page.getByRole('button', { name: 'Add to cart' }).click();
  await page.goto('/cart');
  await page.getByRole('button', { name: 'Checkout' }).click();
  await expect(page).toHaveURL(/\/orders\/\w+/);
});

Test pyramid CI distribution (GitHub Actions)

jobs:
  unit:
    runs-on: ubuntu-latest
    steps:
      - run: pnpm test:unit  # <30s, every push
  integration:
    needs: unit
    steps:
      - run: pnpm test:integration  # <5min, every PR
  e2e:
    needs: integration
    if: github.ref == 'refs/heads/main'
    steps:
      - run: pnpm test:e2e  # <20min, main only

Coverage budget enforcement

// vitest.config.ts
export default {
  test: {
    coverage: {
      thresholds: {
        lines: 80,
        functions: 80,
        branches: 75,
        statements: 80,
      },
    },
  },
};

매 결정 기준

상황 Approach
Pure logic, no I/O Unit test
DB query / external HTTP Integration with testcontainers
Microservice boundary Contract test (Pact)
Critical user journey E2E (smoke only, 5-10 tests)
Visual regression Playwright trace + screenshot

기본값: 70/20/10 split (unit/integration/e2e), 매 contract test 는 microservice 환경에서만.

🔗 Graph

🤖 LLM 활용

언제: test strategy 설계, CI tier 분배 결정, anti-shape 진단. 언제 X: 매 specific test framework 의 deep API 질문 — 매 official docs 의 우선.

안티패턴

  • All e2e: 매 30분 CI, flaky retry hell.
  • No integration: unit pass + production fail (mock drift).
  • Test pyramid as goal: 매 ratio 의 obsession — 매 actual confidence 가 metric.
  • 100% coverage: meaningless — 매 critical path coverage 가 진짜.

🧪 검증 / 중복

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — full canonical content with 4-layer modern pyramid