First Semester Examinations 2018 1 SEMESTER 1, 2018 EXAMINATIONS CITS5501 Software Testing and Quality Assurance This paper contains: 7 pages (including title page) Time allowed: 2 hours (including reading time) Instructions: Total marks: 50 marks • Candidates should attempt all 5 of the questions. • Each question is worth TEN (10) marks. • Please start each question on a new page Candidates may bring one A4 page of notes to the examination. These notes must be hand written, not photocopied or printed and may be written on both sides of one A4 page. The page can not be folded or have any attachments. Any notes that do not meet these conditions will be considered unauthorized material, and will be removed by the exam invigilators. Your notes page must be submitted with your exam paper at the end of the exam. Books and calculators may NOT be taken into the examination room. Exam papers are to be collection with the examination answer booklets. replace this page with official cover page 1 First Semester Examinations 2018 2 replace this 2nd page with official cover page 2 (that is, “this page has been left blank”) First Semester Examinations 2018 3 1. Consider a Python file, “word counting.py”, containing a single function: X # count the number of unique words in the string "aString" # (where a "word" is a contiguous sequence of non-whitespace # characters). # If "aString" is not a string, the result is undefined. def wordCount(aString): words = aString.split() uniqueWords = [] count = 0 for word in words: if word not in uniqueWords: count += 1 uniqueWords.append(word) return count Using input space partitioning, describe some partitions from which test cases for this function could be drawn, showing your working. Describe three unit tests derived from those partitions. You need not present code for the unit tests, but should clearly describe the input and expected results. Then, write an example of a doctest-based test for wordCount(), which could be included in the docstring for the function. [10 marks] First Semester Examinations 2018 4 2. Consider the following Java implementation of the wordCount() function (as a static method). X 1 public static int wordCount(String aString) { 2 aString = aString.trim(); // trim whitespace from either end 3 4 // handle case where string has no words 5 if (aString.length() == 0) { 6 return 0; 7 } 8 9 String words[] = aString.split("\\s+"); 10 11 ArrayList
uniqueWords = new ArrayList<>();
12 int count = 0;
13 for (int i = 0; i < words.length; i++) {
14 String w = words[i];
15 if (! uniqueWords.contains(w) ) {
16 count += 1;
17 uniqueWords.add(w);
18 }
19 }
20 return count;
21 }
Draw a control-flow graph for the method. (You need not consider the effect on control
flow of any called methods, functions or operators, e.g. .split(), nor of any exceptions
that could be thrown.) You should give each node a label (e.g. “A”, “B”, “C” etc.) and
clearly label which lines (or portions of lines) in the listing each node corresponds to.
Then, identify 3 simple paths through the control flow graph, including at least one prime
path, stating which simple paths are also prime paths, and state how you could use prime
paths to evaluate the coverage of a set of unit tests for the wordCount method.
[10 marks]
First Semester Examinations 2018 5
3. You are on the software quality assurance team for Rook Capital, which specialises in
executing trades for stock and futures brokers. The software development team is working
on a program, “UBAR” (“Unbelievably Brisk Automatic Ratiocinator”) for automatically
executing trades. It takes as input sets of rules (effectively, programs described in a simple
language) supplied by Rook Capital’s clients, monitors stock prices, and automatically
executes trades based on the rules. An incorrectly executed trade could result in enormous
losses for clients, so it is important the system be highly reliable: it should function
correctly, transmit data securely, and have minimal downtime.
XDescribe a quality assurance strategy you would use to ensure a high-quality system is
delivered. There should be at least three different elements to your strategy. For each
element, you should provide an example of how it could be applied (e.g. a test case, or a
scenario demonstrating its application).
[10 marks]
First Semester Examinations 2018 6
4. An automatic door system has a sensor pad on both sides of the door (call them “front”
and “rear”). Each sensor pad can detect the weight of a person stepping onto it. Assume
that to pass through the door, a person will have to step onto one sensor pad, then the
other. Initially, the door is closed. If a person is detected on either sensor pad, it opens.
Once open, it stays open until neither sensor pad reports a person on it. It then waits
two seconds, and if no person is detected, it closes. Draw a state diagram for the system.
XNow suppose you are devising tests for the system. List the prime paths through the
system, as well as a set of paths which give edge coverage.
[10 marks]
First Semester Examinations 2018 7
5. You are part of a team developing an online, searchable genealogy database called
“FindMyAncestors.com”, and you are using the Alloy analyzer to develop a formal model
of your system.
XYour team has identified the following entities, relationships and constraints which your
system should represent:
• The system models relationships between Person entities.
• A person has a set of parents, and a set of siblings.
• A person cannot be their own parent.
• A person cannot be their own sibling.
• If we have two people, a and b, and a has b amongst their siblings, then b must be
amongst a’s siblings.
• In addition to parents, a person has a set (possibly empty) of ancestors, defined as
follows. For any person a:
– If person b is the parent of person a, then b is amongst the ancestors of a.
– If person m is one of the ancestors of person a, and person n is a parent of m,
then n is one of the ancestors of a.
– No other people are ancestors of a.
Give Alloy definitions which model a “Person” entity, with the constraints described
above.
[10 marks]
END OF PAPER
学霸联盟