King¡¯s College London
This paper is part of an examination of the College counting toward the award of a degree. Examinations are governed by the College Regulations under the authority of the Academic Board.
Degree Programmes
Module Code Module Title Examination Period
MSc, MSci
7CCSMASE
Advanced Software Engineering January 2019 (Period 1)
Time Allowed 2 hours
Rubric ANSWER ALL QUESTIONS.
Books, notes or other written material may not be brought into this examination.
ANSWER EACH QUESTION ON A NEW PAGE OF YOUR ANSWER BOOK AND WRITE ITS NUMBER IN THE SPACE PROVIDED.
Calculators Calculators may be used. The following models are permitted: Casio fx83 / Casio fx85
PLEASE DO NOT REMOVE THIS PAPER FROM THE EXAMINATION ROOM
King¡¯s College London ý 2019
for the condition of the if statement.
if( (x>0) && (y < 1) ) { z = x/y;
}
(f) Define the notion of stress testing.
(5 marks) (5 marks) [30 marks]
7CCSMASE Advanced Software Engineering
Question 1
(a) Define the notions of structural testing and functional testing and
explain the difference between them. (5 marks) (b) Define the notions of test cases, test suite, and adequacy criteria.
(5 marks)
(c) Explain why it is often impossible to construct a test suite that satisfies the adequacy criteria. Give one example (a small program, a criterion, and why it is impossible to satisfy it).
(5 marks) (d) Define the multiple condition decision coverage (MC/DC) metric.
(5 marks) (e) Write a test suite for the following code snippet with 100% MC/DC
2
SEE NEXT PAGE
7CCSMASE Advanced Software Engineering
Question 2
For the following program, which decides whether the input positive integer number n is prime:
int prime(int n)
{
int i;
int flag;
for(i = 2; i <= n/2; i++) {
if(n%i == 0){
\\comment: % is modulo operation, calculating a remainder of division
flag = 1;
break; \\comment: exit the loop
} else {
flag=0;
} }
return flag;
}
(a) Draw the control graph of the program.
(b) Annotate the nodes to indicate the definitions/uses of variables n,
(6 marks) i, and flag. (6 marks)
(c) What is a potential error in the program that is found analysing the definition/use pairs from sub-question (b)? Show how it is found. Is it a real error? If no, explain why. If yes, when is it manifested?
3
(6 marks) SEE NEXT PAGE
7CCSMASE Advanced Software Engineering (d) Define one structural coverage metric suitable for this program.
(5 marks)
(e) Build a minimal test suite having 100% coverage according to the criterion defined in sub-question (d). A test suite is minimal if removing any test from it will result in a lower coverage. (6 marks)
(f) Addacodetotheprogramindefensiveprogrammingstyle,to make sure that n is indeed positive. After the addition, does it still have 100% coverage according to the criterion you defined? Explain
your answer.
(6 marks)
[35 marks]
4
SEE NEXT PAGE
the criterion in (c).
(6 marks)
[35 marks]
7CCSMASE Advanced Software Engineering
Question 3
(a) Write a set of natural language requirements for a vending machine for two types of chocolate bars, accepting at least two types of coins, and not giving change or money back. (6 marks)
(b) Draw a Finite State Machine (FSM) M that is a reference model for the vending machine as described in (a). (6 marks)
(c) Suggest one suitable coverage criterion for M. Justify your answer.
(5 marks)
(d) Construct a minimal test suite that has 100% coverage according to the criterion you described in (c). A minimal test suite is a test suite such that removing one test from it would decrease the coverage.
(6 marks)
(e) After you show the prototype of the vending machine to the customer, the customer adds another requirement: that there is a reset button that is enabled at every step before the chocolate is dispensed. Describe how you change M to satisfy this requirement. Draw the modified FSM M¡¯.
(6 marks)
(f) Does the test suite you constructed in (d) still have 100% coverage in M¡¯? If the answer is `yes¡¯, explain why. If the answer is `no¡¯, construct a minimal test suite with 100% coverage of M¡¯ according to
5
S E E N EFXI NT APLA GP AE G E