Q.1.
(a) In the example (pseudo) code below, write the minimum number of test cases (specify the test data that you would use in each case) required to achieve 100% statement coverage and 100% branch coverage.
Example 1 Test Cases
Statement Coverage Branch coverage
If x=23 then
DoThis
DoThat
DoOther
Endif
Example 2 Test Cases
Statement Coverage Branch coverage
If p=true then
DoThis
DoThat
Else
DoOther
Endif
Example 3 Test Cases
Statement Coverage Branch coverage
If p=true then
If x=23 then
DoThis
DoThat
EndIf
Else
DoOther
Endif
Example 4 Test Cases
Statement Coverage Branch coverage
If p=true then
If x=23 then
DoThis
DoThat
Else
DoOther
Endif
Else
DoLittle
Endif
Table 1
(b) A company’s employees are paid bonuses if they work more than a year in the company and achieve targets that have been agreed. The following decision table has been designed to test the system. Which test conditions can be eliminated in the above decision table because the test case wouldn’t occur in a real situation? Give reasons for your answers.
(c) A cinema uses the following categories to determine ticket prices.
Customer type: Child, Teen, Adult, Senior
Start time: Off-peak, Peak, Weekend
Film type: 2D, 3D
Seat type: Normal, VIP, Bean bag, hammock
Given the following test cases:
• Child, Peak, 2D, Normal
• Adult, Peak, 2D, Normal
• Teen, Peak, 3, Bean bag
• Senior, Weekend, 2D, Bean bag
• Child, Off-peak, 2D, Hammock
• Adult, Weekend, 2D, VIP
Which of the following combinations of test cases provides the highest level of coverage for equivalence partitioning? Explain your answer.
• i, ii and vi
• i, ii and iv
• ii, iii and v
• i, iv and vi
(d) Delegates sitting an exam are awarded a grade based on their performance in relation to the other delegates sitting the same exam. The top 10% are given a grade A, the next 15% a grade B, the next 25% a grade D and the remainder an E. This year 100 delegates sat the exam. In which of the following would delegates fall into three different equivalence classes. Explain your answer.
• Derek was 9th, Eve was 12th and Tricia was 16th
• Edward was 15th, Julia was 30th and Mike was 90th
• Joanna was 15th , Andrew was 25th and Carol was 30th
• Sam was 50th , Will was 51st and Sarah was 80th