NivaarExam PrepOfficial exam papers ↗

25-Comp-A6 Software Engineering · December 2014

Question 5 of 10: Software Testing

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

National Exams — December 2014 — 98-Comp-A6 Software Engineering. Three-hour, closed-book exam, no calculator permitted. Format: ten questions, candidates answer any six (all questions equal weight — each question carries 20 marks, so the paper is marked out of 120; only the first six questions as they appear in the answer book are marked). All ten questions are solved below for completeness.

Reference texts: Sommerville, Software Engineering (10th ed., Pearson) — software process models, object-oriented and function-oriented design, real-time systems, software testing, configuration management, dependable/critical systems, reliability engineering, component-based software engineering; Pressman, Software Engineering: A Practitioner's Approach (9th ed.) — supplementary process/testing/quality coverage; IEEE/ISO 12207 — software life-cycle processes; SWEBOK — body-of-knowledge cross-reference.

Question 5: Software Testing (a) 5, (b) 5, (c) 10 — 20 marks

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

(a) Why Testing Only Shows the Presence of Errors

A test suite exercises the program on a finite, chosen subset of its (typically astronomically large or infinite) input space. If any test in that subset fails, the program is provably incorrect — a single failing test is a valid proof of a defect. But if every chosen test passes, that only shows the program behaves correctly on the inputs actually tried; it says nothing about the inputs that were never tried, any one of which could still trigger a defect. Since it is generally infeasible to test every possible input (or every possible execution path/state), passing all tests can never be used to conclude the program is defect-free — only that no defect has yet been found by this particular finite sample.

(b) Regression Testing, and Why Automation Simplifies It

Regression testing is re-running a system's existing test suite after a change (a bug fix, a new feature, a refactor) specifically to check that the change has not broken any previously working behaviour — that the system has not "regressed." It is necessary because software components are rarely as independent as their interfaces suggest: a change made for one purpose can have unintended side effects on unrelated parts of the system through shared state, a changed data format, or a subtle timing dependency, and the only reliable way to catch such a side effect is to re-verify everything that was already known to work, not just the area that was deliberately changed.

Run entirely by hand, regression testing is expensive in direct proportion to how large the existing test suite has grown, which creates a perverse incentive to skip it, run only a hand-picked subset, or run it rarely — exactly the situations in which a regression is most likely to slip through. An automated test suite (each test coded so it runs and checks its own expected result without a human operator) plus a testing framework (the harness that discovers, executes, and reports every test's pass/fail status in one run) removes that cost: the full suite can be re-run after every single change, in minutes, with no incremental human effort per run, which is precisely why continuous-integration pipelines re-run the whole regression suite on every commit rather than only before a release. Automation also makes regression testing repeatable in the strict sense — the same test executes the same steps and applies the same pass/fail criterion every time, removing the variability of a human tester re-deriving "does this still look right" by eye on each run, which both catches subtler regressions and makes a failure immediately attributable to the specific change that introduced it.

(c) Test Cases

1. Integer array sort routine

Test casePurpose
Empty arrayBoundary: zero elements
Single-element arrayBoundary: trivially sorted
Already-sorted arrayBest-case / no-op behaviour
Reverse-sorted arrayWorst-case ordering
Array with duplicate valuesStability/tie-handling of equal keys
Array with negative and positive valuesCorrect ordering across sign
Array with all identical elementsDegenerate case, no distinct ordering
Array containing INT_MIN / INT_MAXBoundary values of the integer type
Large random arrayGeneral-case correctness at scale

2. Non-blank character counter

Test casePurpose
Empty lineBoundary: zero-length input, expect count 0
Line of all blanksExpect count 0
Line with no blanks at allExpect count = line length
Line with mixed blank and non-blank charactersGeneral case
Line with leading and/or trailing blanksBlanks at the boundary of the string, not just interior
Line containing tab charactersClarifies whether "blank" means space only or any whitespace
Line with punctuation/special charactersConfirms non-space, non-alphanumeric characters are counted as non-blank
Single-character lineBoundary: smallest non-empty input
Very long lineGeneral-case correctness / buffer handling at scale

3. YYYY/MM/DD date-validation module

InputExpected resultPurpose
2011/1/1ValidGiven worked example — single-digit month and day, both allowed
1990/12/25ValidGiven worked example — two-digit month and day
1250/03/18ValidGiven worked example — leading zero on a two-digit month
2016/02/29ValidBoundary: February 29 in a leap year (2016 divisible by 4)
2015/02/29InvalidBoundary: February 29 in a non-leap year
2000/02/29ValidCentury-year leap-rule boundary (2000 is divisible by 400, hence a leap year despite being a century year)
1900/02/29InvalidCentury-year leap-rule boundary (1900 is divisible by 100 but not 400, hence NOT a leap year)
2014/00/15InvalidBoundary: month 0 is out of range
2014/13/15InvalidBoundary: month 13 is out of range
2014/04/00InvalidBoundary: day 0 is out of range
2014/04/31InvalidDay out of range for a 30-day month
201/05/12InvalidYear is only 3 digits — spec requires exactly 4
20145/05/12InvalidYear is 5 digits — spec requires exactly 4
2014/5/012InvalidDay has 3 digits — spec allows only 1 or 2
 2014 / 5 / 1 ValidSpaces around the digit groups are explicitly to be ignored per the spec
2014-05-01InvalidWrong separator character (hyphen instead of slash)
2014//5/1InvalidMalformed separators / missing field
Check
The leap-year rule applied above (divisible by 4, except century years, which must also be divisible by 400) is the standard Gregorian calendar rule and is the only reading consistent with the spec's own example date 1990/12/25 being an ordinary (non-leap-sensitive) case; the two century-boundary test rows (2000 and 1900) specifically target the part of that rule a naive "divisible by 4" implementation gets wrong.