AS Level · Topic 12.3
A-Level Computer Science 9618 / Topic 12 / AS

Test it, then keep it working.

Good testing is planned, not random. A test plan sets out exactly which data to try and what should happen, using normal, abnormal, extreme and boundary data. And once the program is in use, the work is not over: it must be maintained for as long as people rely on it.

The key idea

Normal data is typical data that should be accepted. Abnormal (erroneous) data should be rejected: out of range or the wrong type. Extreme data is the largest or smallest value that is still accepted. Boundary data tests each side of a limit: the last value accepted and the first value rejected. A test strategy sets out the overall approach to testing; a test plan lists each test with its data, its type and the expected result. After release a program needs maintenance: corrective (fix errors), adaptive (change it for new requirements or a new environment) and perfective (improve it, for example its speed or ease of use).

Tickets: a whole number from 1 to 10 is accepted accepted range: 1 to 10 −1012345 6789101112 NormalExtremeBoundaryAbnormal −3, 25, 4.5, “two” (all rejected) filled dot = should be accepted; hollow red dot = should be rejected
Fig. 1: test data for an input that accepts a whole number of tickets from 1 to 10
Section 01

Choosing test data.

In the lab, the age check accepts 11 to 18. Try each kind of test data in turn and see which values the program accepts and which it rejects.

TypeMeaningTickets, 1 to 10 (Fig. 1)
NormalTypical, sensible data that should be accepted4, 7
AbnormalData that should be rejected: outside the range, or the wrong type−3, 25, 4.5, "two"
ExtremeThe largest and smallest values that are still accepted1 and 10
BoundaryValues either side of each limit: the last accepted and the first rejected0 and 1; 10 and 11
Worked example Test data for a length check
A password must be from 8 to 16 characters long. Give test data of each type.
  1. Normal: a password of 12 characters (accepted).
  2. Extreme: passwords of exactly 8 and exactly 16 characters (both accepted).
  3. Boundary: 7 characters (rejected) and 8 (accepted); 16 (accepted) and 17 (rejected).
  4. Abnormal: 3 characters or 30 characters, or an empty string (all rejected).
Answer: Normal 12; extreme 8 and 16; boundary 7/8 and 16/17; abnormal e.g. 3, 30 or empty
Examiner trap

Always give the expected outcome with your test data, and give the actual value, not a description. "A number just outside the range" earns nothing; "11, rejected" does.

Section 02

Strategy and plan.

Testing has to be planned during design, before coding starts, so that it is thorough and can be repeated after every change.

No.PurposeTest dataTypeExpected resultActual result
1Typical value accepted4NormalAccepted
2Lowest valid value accepted1ExtremeAccepted
3Value just below the range rejected0BoundaryRejected, error message
4Highest valid value accepted10ExtremeAccepted
5Value just above the range rejected11BoundaryRejected, error message
6Non-integer rejected4.5AbnormalRejected, error message
7Wrong data type rejected"two"AbnormalRejected, error message
Your turn
A test plan for a mark input (0 to 100) has a test with data 101. State its type and expected result.
Examiner trap

The actual result column is empty in the plan: it is filled in when the test is carried out. Do not confuse the test plan (written in design) with the test results.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

An input accepts whole numbers from 1 to 10. Which value is extreme data?

Quick check+10 XP

In the lab, the age check accepts 11 to 18. Which pair is boundary data for the lower limit?

Quick check+10 XP

Which column is filled in only when the test is carried out?

Quick check+10 XP

A program is changed because a new law changes how VAT is calculated. Which type of maintenance is this?

Section 03

Keeping it working.

Programs are often used for years, while bugs surface, laws and hardware change, and users want more. Maintenance is the longest and often the most expensive stage of the life cycle.

TypeWhy it is neededExample
CorrectiveTo fix errors (bugs) found after the program is in useA report crashes when a class has no students
AdaptiveTo change the program for new requirements or a changed environmentA new tax rate becomes law; a new operating system is installed
PerfectiveTo improve a program that already works, e.g. make it faster or easier to useA search is rewritten to run in half the time

A cinema's ticket function charges 12.50 per ticket. The cinema now gives 10% off orders of 5 or more tickets. The function is analysed and amended to add this functionality:

// before
FUNCTION TicketPrice(Tickets : INTEGER) RETURNS REAL
    RETURN Tickets * 12.50
ENDFUNCTION

// after: 10% discount for 5 or more tickets
FUNCTION TicketPrice(Tickets : INTEGER) RETURNS REAL
    DECLARE Price : REAL
    Price ← Tickets * 12.50
    IF Tickets >= 5 THEN
        Price ← Price * 0.9
    ENDIF
    RETURN Price
ENDFUNCTION
Worked example Test the amendment
Choose test data to check the amended TicketPrice and give the expected results.
  1. Normal, no discount: 2 tickets: 2 × 12.50 = 25.00.
  2. Boundary just below the discount: 4 tickets: 4 × 12.50 = 50.00.
  3. Boundary at the discount: 5 tickets: 62.50 × 0.9 = 56.25.
  4. Normal, with discount: 8 tickets: 100.00 × 0.9 = 90.00.
Answer: 2: 25.00; 4: 50.00; 5: 56.25; 8: 90.00
Your turn
Which type of maintenance is the cinema's change? Give a reason.
Examiner trap

Corrective maintenance fixes something that was wrong. If the program was correct but the world or the requirements changed, it is adaptive; if it worked but is being made better, it is perfective.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to AS Paper 1 and Paper 2 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

A field accepts a percentage from 0 to 100. Which set of test data is all abnormal?

Exam style+20 XP

What is included in a test plan?

Exam style+20 XP

Users report that a program works correctly but takes too long to load. The developers rewrite it to load faster. Which type of maintenance is this?

Exam style+20 XP

Why is a test strategy needed?

Skill unlocked

Test data and maintenance, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
Normal, abnormal, extreme and boundary data, test strategies and test plans, the three types of maintenance, and amending a program.