UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS
INFR10057 SOFTWARE TESTING
Friday 3 rd May 2019 14:30 to 16:30
INSTRUCTIONS TO CANDIDATES
Answer QUESTION 1 and ONE other question. QUESTION 1 is COMPULSORY.
All questions carry equal weight.
This is an OPEN BOOK examination.
You may consult any books or other documents during this examination.
The use of Calculators is permitted.
Year 3 Courses
Convener: C. Stirling
External Examiners: S.Rogers, S. Kalvala, H.Vandierendonck
THIS EXAMINATION WILL BE MARKED ANONYMOUSLY
1. THIS QUESTION IS COMPULSORY.
Consider the following function that finds the sum of all positive integers, below an input number n, that are divisible by 3 or 5.
1 2 3 4 5
public static long getSum(long n) {
long sum = 0;
for (int i = 3;
i
high = mid – 1;
} else if (sortedArray[mid] == key) {
index = mid;
break; }
}
return index;
}
Page 4 of 6
3. (a)
Why is interclass testing in OO programs carried out? Explain how inter- class testing is typically carried out.
(b) For the following class diagram of ATM transactions, draw the use-include hierarchy. Which interactions would you test in the class diagram?
Figure 1: Question 3b: Class Diagram of ATM Trasactions
(c) For the following specification, illustrate steps involved in TDD. As part of the steps, the code that you write can be in the form of pseudo-code or a programming language of your choice. For the purpose of the exam, do not worry about the syntactical correctness of the code. You only need to focus on program logic and their correspondence to tests developed.
Take a list of integers and size of the list as inputs,
Spec 1: If size of list is 0 or greater than 50, return -100.
Spec 2: If any number in the list is negative, return -1.
Spec 3: If there are no negative numbers and
if any number in the list is zero, return 0.
Spec 4: If all numbers in the list are positive,
return maximum value.
QUESTION CONTINUES ON NEXT PAGE
Page 5 of 6
[3 marks] [6 marks]
[8 marks]
1
public ArrayList
QUESTION CONTINUED FROM PREVIOUS PAGE
(d) Discuss the pros and cons of the two testing techniques, mutation-based fuzzing and generation-based fuzzing, used in security testing.
(e) For the following function that computes factors of an integer input a, create one mutation that ¡°replaces an arithmetic operator¡± and another mutation that ¡°replaces a constant by a scalar variable¡±. Provide both mutations by only showing the changed line in each. Present tests to reveal each of these two mutations, showing input, expected output and actual output.
[4 marks]
[4 marks]
2
3
4
5
6
7
8 9} 10 }
11 }
12 Collections.sort(factors);
13 return factors;
14 }
int upperlimit = (int)(Math.sqrt(a));
ArrayList
for(int i=1;i <= upperlimit; i+= 1){
if(a%i == 0){
factors.add(i);
if(i != a/i){
factors.add(a/i);
Page 6 of 6