程序代写代做代考 graph C King’s College London

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 2018 (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 © 2018

7CCSMASE Advanced Software Engineering
Question 1
(a) Define the notions of white box testing and black box 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) Give two reasons why we need coverage metrics. (5 marks)
(e) Define the notion of random testing. Give one reason in favour of
using it and one reason against using it.
(f) Explain the difference between reliability and safety.
[30 marks]
2
SEE NEXT PAGE
(5 marks) (5 marks)

7CCSMASE Advanced Software Engineering
Question 2
For the following program computing the greatest common divisor:
public int kcl(int x, int y){ int a;
int b;
while( (y ≤ 10) && (x ≥ 0) ) { a = a*y; b = b-x; y++; x–;
}
return a+b; }
(a) Draw the control graph of the program.
(b) Annotate the nodes to indicate the definitions/uses of variables
(6 marks) tmp, x and y. (6 marks)
(c) There is an error in the program that is related to the definitions and uses of variables. Describe the error and demonstrate it by analysing the definition-use pairs that you constructed in sub- question (b). (6 marks)
(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). (6 marks)
(f) Addastatementtotheprogramindefensiveprogrammingstyle. After the addition, does it still have 100% coverage according to the criterion you defined? Explain your answer. (6 marks)
[35 marks]
3
SEE NEXT PAGE


Release item after receiving 20 cents.
o Single coin slot for dimes (10 cents) and nickels (5 cents) –
assuming sensor specifies coin type.
o Machine does not give change.
o It is possible to press a reset button before the amount reaches
20 cents; in this case, the money is returned.
(a) Draw a Finite State Machine (FSM) that is a reference model for the vending machine as described in the question. The inputs to the vending machine are: N (nickel), D (dime), R (reset). There is one output C (the chocolate bar). (6 marks)
(b) Show the paths through the FSM on the following sequences of inputs:
1) Four nickels;
2) Two dimes;
3) Three nickels and one dime; 4) One nickel, one dime, reset.
(6 marks)
(c) What would change if the machine had the option to dispense two types of chocolate bars: type A and type B? Both bars cost the same (20 cents), but there are two additional buttons: one for bar A and one for bar B. The reset button works as before. (6 marks)
(d) Give the definition of branch coverage for FSM. (5 marks) (e) Build a minimal test suite with 100% branch coverage for the FSM
in sub-question (a). (6 marks)
(f) Give the definition of path coverage for FSM. Can we get 100% path coverage? If yes, give a test suite with 100% path coverage. If no, explain why it is impossible to get 100% path coverage, and what
7CCSMASE Advanced Software Engineering
Question 3
Natural language requirements for a vending machine for a single type of a chocolate bar are as follows:
paths we can and cannot cover.
(6 marks)
[35 marks]
4
S E E N EFXI NT APLA GP AE G E