Menu
ESC

Nhập từ khóa để tìm kiếm

↑↓ Di chuyển
Enter Mở
ESC Đóng

Đang tải...

Bài 19 — Test Coverage — Code vs Requirement

Test Strategy and QA Leadership Bài 19/60

Test Coverage

2 loại coverage chính

Code coverage

% code executed bởi test.
  • Line coverage — line executed.
  • Branch coverage — if/else branch covered.
  • Function coverage — function called.
  • Path coverage — all execution path (exponential, rarely 100%).
Tools: Istanbul (JS), Coverage.py, JaCoCo (Java), Slather (iOS).

Requirement coverage

% requirements covered by test case.
  • Map: requirement ID → test case ID.
  • Tools: TestRail, Xray, qTest.

Common targets

  • Line coverage: 80%.
  • Branch coverage: 70%.
  • Critical user journey: 100%.
  • Requirement: 100% for critical, 80% overall.

Anti-pattern

  • 100% line coverage không = test tốt. Test có thể just call function, không assert.
  • Chase coverage number → test trivial code (getter/setter).
  • Skip difficult code (error handling) → low value coverage.

Gold standard

  • Mutation testing — Stryker, PIT.
  • Insert random bug → does test catch? Real signal of test quality.

Coverage trend

  • Day 1: 30%.
  • Sau onboarding: 60%.
  • Mature: 80%.
  • Diminishing return > 85%.

VN team practice

Banking app: > 80% mandatory. Startup: aim 60%, focus quality > quantity.

Coverage by code type

  • Business logic: 90%+.
  • UI: 60-70%.
  • Generated code: skip from report.
  • 3rd-party wrapper: 50%.