QuestionQ12

VerifiedTesting in Agile

Consider this code fragment:

If (a>b) and (b>c) then -  
b = (a+c)/2  
endif  

Assume that, in the options below, each parenthesized set of three numbers represents the inputs for a test case: the first number represents variable "a", the second represents variable "b", and the third represents variable "c".

Which of the following provides a set of test-case inputs that achieves 100% decision coverage for this code fragment using the minimum number of test cases?

Explanation

100% decision coverage requires the compound condition (a > b) and (b > c) to produce both True and False outcomes. (5, 4, 0) makes the condition True, while (4, 5, 0) makes it False because a > b is false. These two cases achieve both outcomes with the minimum of two test cases.

Community Discussion

No comments yet. Be the first to start the discussion!