Statement and Decision Coverage Questions
Q. 1: Analyse the following highly simplified procedure:
Ask: “What type of ticket do you require, single or return?”
IF the customer wants ‘return’
Ask: “What rate, Standard or Cheap-day?”
IF the customer replies ‘Cheap-day’
Say: “That will be £11:20”
ELSE
Say: “That will be £19:50”
ENDIF
ELSE
Say: “That will be £9:75”
ENDIF
Now decide the minimum number of tests that are needed to ensure that all
the questions have been asked, all combinations have occurred and all
replies given.
A) 3
B) 4
C) 5
D) 6
Q. 2: Given the following:
Switch PC on
Start “outlook”
IF outlook appears THEN
Send an email
Close outlook
A) 1 test for statement coverage, 1 for branch coverage
B) 1 test for statement coverage, 2 for branch coverage
C) 1 test for statement coverage. 3 for branch coverage
D) 2 tests for statement coverage, 2 for branch coverage
E) 2 tests for statement coverage, 3 for branch coverage
Q. 3: Given the following code, which is true:
IF A > B THEN
C = A – B
ELSE
C = A + B
ENDIF
Read D
IF C = D Then
Print “Error”
ENDIF
A) 1 test for statement coverage, 3 for branch coverage
B) 2 tests for statement coverage, 2 for branch coverage
C) 2 tests for statement coverage. 3 for branch coverage
D) 3 tests for statement coverage, 3 for branch coverage
E) 3 tests for statement coverage, 2 for branch coverage
Q. 4: Consider the following:
Pick up and read the newspaper
Look at what is on television
If there is a program that you are interested in watching then switch the the television on
and watch the program
Otherwise
Continue reading the newspaper
If there is a crossword in the newspaper then try and complete the crossword.
A) SC = 1 and DC = 1
B) SC = 1 and DC = 2
C) SC = 1 and DC = 3
D) SC = 2 and DC = 2
E) SC = 2 and DC = 3
Q. 5: Given the following code, which statement is true about the minimum number of
test cases required for full statement and branch coverage?
Read P
Read Q
IF P+Q > 100 THEN
Print “Large”
ENDIF
If P > 50 THEN
Print “P Large”
ENDIF
A) 1 test for statement coverage, 3 for branch coverage
B) 1 test for statement coverage, 2 for branch coverage
C) 1 test for statement coverage, 1 for branch coverage
D) 2 tests for statement coverage, 2 for branch coverage
Q. 6: Consider the following statements:
i. 100% statement coverage guarantees 100% branch coverage.
ii. 100% branch coverage guarantees 100% statement coverage.
iii. 100% branch coverage guarantees 100% decision coverage.
iv. 100% decision coverage guarantees 100% branch coverage.
v. 100% statement coverage guarantees 100% decision coverage.
A) ii is True; i, iii, iv & v are False
B) i & v are True; ii, iii & iv are False
C) ii & iii are True; i, iv & v are False
D) ii, iii & iv are True; i & v are False
Q. 7: A white box testing technique that measures the number of or percentage of
decision directions executed by the test case designed is called
A. Boundary Value coverage
B. Decision/Condition coverage
C. Statement Coverage
D. None of Above
Q. 8: This part of a program is given:
WHILE (condition A)
Statement 1..
Statement 2..
END WHILE
How many decisions should be tested in this code in order to achieve 100% decision
coverage?
A. 2
B. Indefinite
C. 1
D. 4
Q. 9: Branch Coverage is
A. Another name for decision coverage
B. Another name for statement coverage
C. Another name for basic path coverage
D. All the above
Q. 10: Given the following fragment of code, how many tests are required for 100%
decision coverage?
if width > length then
biggest_dimension = width
if height > width then
biggest_dimension = height
end_if
else
biggest_dimension = length
if height > length then
biggest_dimension = height
end_if
end_if
A. 3
B. 4
C. 2
D. 1
Q. 10: Given the following fragment of code, how many tests are required for 100%
decision coverage?
if width > length then
biggest_dimension = width
if height > width then
biggest_dimension = height
end_if
else
biggest_dimension = length
if height > length then
biggest_dimension = height
end_if
end_if
A. Another name for decision coverage
B. Another name for statement coverage
C. Another name for basic path coverage
D. All the above
Q. 11: You have designed test cases to provide 100% statement and 100% decision coverage for the following fragment of code.
if width > length then
biggest_dimension = width
else
biggest_dimension = length
end_if
The following has been added to the bottom of the code fragment above.
print "Biggest dimension is " & biggest_dimension
print "Width: " & width
print "Length: " & length
How many more test cases are required?
A. One more test case will be required for 100 % decision coverage.
B. Two more test cases will be required for 100 % statement coverage, one of which will be used to provide 100% decision coverage.
C. None, existing test cases can be used.
D. One more test case will be required for 100″ statement coverage.



