Skip to content
CodeKruPro

Statement coverage versus branch coverage

QuizMedium

Statement coverage is the share of statements (single instructions, often one per line) that the tests run. Branch coverage is the share of decision outcomes (true and false) that the tests take. Here is some logic written as pseudo-code (plain steps written like code, not in a real language):

discount = 0
IF amount > 1000 THEN
    discount = 10
END IF
total = amount - discount

Your only test uses amount = 2000. Which statement is true?

  • Statement coverage is 100%, but branch coverage is not; add a test with an amount of 1,000 or less
  • Statement and branch coverage are both 100%
  • Branch coverage is 100%, but statement coverage is not
  • Neither can be measured without the source code in a real language

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in