Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
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