Files
2nd/10_Wiki/Topics/DevOps_and_Security/Quality-Control.md
T
2026-05-10 22:08:15 +09:00

5.5 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-quality-control Quality Control 10_Wiki/Topics verified self
QC
Software Quality
none A 0.9 applied
quality
testing
process
2026-05-10 pending
language framework
TypeScript/Python Playwright/pytest

Quality Control

매 한 줄

"매 quality 의 inspect 보다 build-in". 매 modern QC 의 shift-left — 매 unit test, type checking, static analysis, contract test, e2e — 매 layer 의 different bug class catch. 2026 의 LLM-augmented test generation + property-based testing 의 mainstream.

매 핵심

매 Test pyramid (2026 update)

  • Unit (60-70%): pure function, fast, isolated.
  • Integration (15-25%): module + DB/queue, real dependencies via testcontainers.
  • E2E (5-10%): full user journey, Playwright/Cypress.
  • Contract (5%): Pact, consumer-driven, prevent break-on-deploy.
  • Property-based (cross-cutting): Hypothesis/fast-check, find edge cases.

매 Quality gates

  • 매 PR 의 merge 전: lint, type, unit test, coverage threshold, security scan.
  • 매 deploy 전: integration test, smoke test, canary metrics.
  • 매 prod: synthetic monitoring, real-user monitoring (RUM).

매 Defect classes

  • Functional: wrong output for given input.
  • Performance: slow, regression on benchmark.
  • Security: OWASP categories.
  • Accessibility: WCAG violations.
  • Compatibility: browser/OS specific.

매 응용

  1. CI/CD pipeline gates.
  2. Pre-merge bots (Danger, Reviewdog).
  3. Mutation testing (Stryker) — quality of tests themselves.
  4. Visual regression (Chromatic, Percy).
  5. Chaos engineering (production resilience).

💻 패턴

Property-based testing (TypeScript with fast-check)

import fc from 'fast-check';
import { reverse } from './lib';

test('reverse twice = identity', () => {
  fc.assert(
    fc.property(fc.array(fc.integer()), (arr) => {
      expect(reverse(reverse(arr))).toEqual(arr);
    }),
  );
});

Contract test (Pact)

// Consumer side
const provider = new Pact({ consumer: 'Web', provider: 'OrdersAPI' });

await provider.addInteraction({
  state: 'order 123 exists',
  uponReceiving: 'a request for order 123',
  withRequest: { method: 'GET', path: '/orders/123' },
  willRespondWith: {
    status: 200,
    body: { id: '123', total: 99.0 },
  },
});

// Generates pact.json — provider verifies against it in CI

Mutation testing (Stryker)

// stryker.conf.js
export default {
  testRunner: 'vitest',
  mutate: ['src/**/*.ts'],
  thresholds: { high: 80, low: 60, break: 50 },
};
// Mutates code (a + b → a - b) and checks if tests catch it
// Surviving mutants = weak tests

LLM-assisted test generation (2026 pattern)

// CI step: claude-code generates edge cases
// $ claude test-gen src/parser.ts --output tests/parser.gen.test.ts
// Then human review before merge — never blind-trust

Visual regression (Playwright)

test('homepage matches snapshot', async ({ page }) => {
  await page.goto('/');
  await page.waitForLoadState('networkidle');
  expect(await page.screenshot()).toMatchSnapshot('home.png', {
    maxDiffPixelRatio: 0.01,
  });
});

Coverage gates (vitest)

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

Pre-commit hook (lint-staged + husky)

{
  "lint-staged": {
    "*.{ts,tsx}": [
      "eslint --fix",
      "prettier --write",
      "vitest related --run"
    ]
  }
}

Chaos test (Toxiproxy / Litmus)

# Inject 500ms latency into Redis dependency
apiVersion: chaos-mesh.org/v1alpha1
kind: NetworkChaos
spec:
  action: delay
  selector:
    labelSelectors: { app: redis }
  delay: { latency: 500ms }
  duration: 60s

매 결정 기준

상황 Approach
Pure logic Unit + property-based
Multi-service flow Integration + contract
User journey E2E (sparingly)
Performance regression Benchmark in CI
Visual UI Snapshot + Chromatic
Test confidence Mutation score

기본값: 80% line coverage, mutation score >70%, property-based for parsers/serializers.

🔗 Graph

🤖 LLM 활용

언제: generate edge cases, suggest mutation-resistant assertions, identify untested branches. 언제 X: never let LLM write the assertion AND implementation — confirmation bias.

안티패턴

  • Coverage worship: 100% coverage, 0% assertions ("test executes but checks nothing").
  • Flaky tests ignored: erodes trust in suite. Quarantine and fix immediately.
  • E2E-heavy pyramid: slow, flaky, expensive. Push down to integration/unit.
  • Manual QA only: doesn't scale, regression-prone.
  • No mutation testing: blind to assertion quality.

🧪 검증 / 중복

  • Verified (Google Testing Blog, Mike Cohn pyramid, Stryker docs).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — pyramid + 2026 LLM-assisted patterns