White Box · Structure-Based

Branch Coverage

Exercise every branch from every decision point — both true and false. Branch coverage is stronger than statement coverage and is the standard minimum for most production code.

Senior Test Lead ISTQB CTFL v4.0 — 4.3.2

What it is

Branch coverage (also called decision coverage) measures whether every branch from every decision point in the code has been taken at least once. A decision point is any point where execution can split: if/else, switch, while, for, ternary operators.

For every decision, there are at least two branches: the path taken when the condition is true, and the path taken when it’s false. 100% branch coverage requires both to be tested.

Worked example

Branch coverage on a discount function
function getDiscount(user, total) {
  let discount = 0;
  if (user.isMember) {          // Decision 1: TRUE branch / FALSE branch
    discount = 0.10;
    if (total > 100) {          // Decision 2: TRUE branch / FALSE branch
      discount = 0.15;
    }
  }
  return discount;
}
Minimum test cases for 100% branch coverage
TestInputD1 branchD2 branch
TC1Non-member, any totalFALSE ✓— (not reached)
TC2Member, total ≤ 100TRUE ✓FALSE ✓
TC3Member, total > 100TRUE (already covered)TRUE ✓

Three tests achieve 100% branch coverage — and in doing so, they also achieve 100% statement coverage. Branch coverage always subsumes statement coverage.

vs statement coverage

100% statement coverage is achievable with a single test (member, total = 150). That test never triggers the non-member path or the below-$100 path. Branch coverage forces you to test those paths too.

Rule of thumb: target 100% branch coverage for business logic, utility functions, and validation code. Accept lower thresholds for generated code, UI templates, and error handlers that can’t be practically triggered.

Coverage targets by context

  • Safety-critical / financial code: 100% branch coverage, plus MC/DC (Modified Condition/Decision Coverage)
  • Core business logic: 100% branch coverage
  • Standard application code: 80%+ branch coverage is a common industry target
  • Generated or boilerplate code: exclude from measurement

ISTQB mapping

ISTQB CTFL v4.0 reference
RefTopic
4.3.2Branch Testing and Coverage
FL-4.3.2 K2Explain branch testing and branch coverage
FL-4.3.2 K2Explain the value of branch coverage over statement coverage

Try It — Design for branch coverage

A NZ loyalty rewards function has two decisions (D1, D2). Select the minimum set of test cases needed to achieve 100% branch coverage — both TRUE and FALSE branches of every decision.

Function: calculateReward(user, purchaseAmount)
function calculateReward(user, purchaseAmount) {
  let points = 0;
  if (user.isLoyaltyMember) {          // D1
    points = purchaseAmount * 2;
    if (purchaseAmount >= 100) {       // D2
      points = points * 1.5;            // bonus multiplier
    }
  }
  return points;
}

Select the test cases to include in your branch coverage suite: