Teachers' Portal  /  A-Level Computer Science 9618  /  Software development  /  Test data and maintenance
Lesson pack · A-Level Computer Science 9618 · 12.3 · AS Level

Test data and maintenance

Test it, then keep it working. Good testing is planned, not random.

Student lesson Lab, full screen
At a glance

The shape of the lesson

Topic
Software development
Syllabus reference
Cambridge International AS and A Level Computer Science 9618, 12.3
Level
AS Level
Duration
45 minutes, lab-led; stretches to a 60 minute block (see the contingency notes)
Position in topic
Lesson 5 of 5 in Software development; follows Types of error and testing methods
Central model
Fig. 1: test data for an input that accepts a whole number of tickets from 1 to 10
Cooperative structure
Assessment
Stage 1 check and the exam-style plenary from the student lesson, plus the worksheet as the exit task
Learning objectives

By the end of the lesson, learners can

Section by section
  • Choosing test data: In the lab, the age check accepts 11 to 18.
  • 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.
  • Keeping it working: Programs are often used for years, while bugs surface, laws and hardware change, and users want more.
Key points to leave on the board
  • Normal: typical, accepted. Abnormal: rejected.
  • Extreme: largest and smallest accepted. Boundary: last accepted and first rejected at each limit.
  • Test plan: number, purpose, data, type, expected result, actual result.
  • Maintenance: corrective fixes, adaptive changes, perfective improves.
The core visual model

One picture every idea returns to

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
Lesson sequence

Forty-five minutes, phase by phase

TimePhaseWhat happens in the roomGrouping
0 to 5 minHook: predictOpen with the question in the title, Test it, then keep it working.. Good testing is planned, not random. Put the figure on the board: it is the one picture every idea in the lesson returns to.Whole class, then pairs
5 to 13 minTeach and check: Choosing test dataIn the lab, the age check accepts 11 to 18. Project tab 3 of the lab (Validation and test data) and let a student drive it while the class predicts. Model the worked example Test data for a length check on the board, one line at a time.Whole class, then pairs
13 to 21 minTeach and check: Strategy and planTesting has to be planned during design, before coding starts, so that it is thorough and can be repeated after every change. Your turn: A test plan for a mark input (0 to 100) has a test with data 101. State its type and expected result.Pairs
21 to 30 minTeach and check: Keeping it workingPrograms are often used for years, while bugs surface, laws and hardware change, and users want more. Model the worked example Test the amendment on the board, one line at a time. Your turn: Which type of maintenance is the cinema's change? Give a reason.Think-Pair-Share
30 to 36 minCheckThe four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong.Individual, then whole class
36 to 43 minPlenaryThe exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording.Individual, random call
43 to 45 minExit and homeworkSet the worksheet below (6 questions, 20 marks). Learners self-assess against the objectives before they leave.Individual
Timing and contingency

Protect the parts that carry the learning

The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.

Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.

Cut first if the build overruns: the last check in Keeping it working, never the check or the plenary.

In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.

Running the cooperative task

Think-Pair-Share

Pose the question, give thirty seconds of silent thinking, then a minute to compare with a partner before a few pairs share with the class. The silent minute is the part that cannot be cut.

The full structure, with its variations and the other twelve, is on the cooperative-learning page.

Examiner traps to pre-empt

What to head off, and how

Trap learners fall intoTeaching move that pre-empts it
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.Return to Choosing test data: ask a pair to state the correct version and show it on the lab before moving on.
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.
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.
Worksheet

Test data and maintenance: worksheet

6 questions, 20 marks. Written in the style of the papers; no past paper question is reproduced.

NameClassDate
Q1 · data[4 marks]

A program accepts the number of days of a hotel booking: a whole number from 1 to 28. Give one example of normal, abnormal, extreme and boundary test data, with the expected result for each.

Q2 · explain[3 marks]

Explain the need for a test plan and describe its likely contents.

Q3 · recall[3 marks]

Describe corrective, adaptive and perfective maintenance.

Q4 · apply[3 marks]

Identify the type of maintenance in each case. (a) A shop's program is changed to accept a new payment card. (b) A bug that printed the wrong date on receipts is fixed. (c) A menu is redesigned so tasks need fewer clicks.

Q5 · write[4 marks]

The function returns the delivery charge for an order:

FUNCTION Delivery(OrderTotal : REAL) RETURNS REAL
    RETURN 4.99
ENDFUNCTION

Amend the function so that delivery is free (0) for orders of 50.00 or more, and 4.99 otherwise.

Q6 · data[3 marks]

For the amended Delivery function, give three values of OrderTotal that test the condition, with the expected result for each.

Answer key and marking notes
Q1 · 4 marks
  • Normal: e.g. 7, accepted.
  • Abnormal: e.g. 40 or −2 or "week", rejected.
  • Extreme: 1 or 28, accepted.
  • Boundary: e.g. 0 rejected / 29 rejected (with 1 / 28 accepted).
Q2 · 3 marks
  • Needed so that testing is planned, thorough and repeatable, and results can be checked against what should happen.
  • Contents: test number, purpose / what is being tested, test data, type of test data.
  • Expected result, actual result, pass / fail and any action taken.
Q3 · 3 marks
  • Corrective: fixing errors / bugs found after the program is in use.
  • Adaptive: changing the program to meet new requirements or a changed environment (e.g. new law, hardware or operating system).
  • Perfective: improving a program that works, e.g. its performance or ease of use.
Q4 · 3 marks
  • (a) Adaptive.
  • (b) Corrective.
  • (c) Perfective.
Q5 · 4 marks
  • Keeps the header FUNCTION Delivery(OrderTotal : REAL) RETURNS REAL.
  • IF OrderTotal >= 50.00 THEN
  • RETURN 0 ... ELSE RETURN 4.99 (or assign to a variable and return it).
  • ENDIF ... ENDFUNCTION.
Q6 · 3 marks
  • 49.99: 4.99 (just below the limit).
  • 50.00: 0 (at the limit).
  • A normal value either side, e.g. 20.00: 4.99 or 80.00: 0.
Quiz

6 multiple-choice questions on this lesson

From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.

Q11 mark

Which of these describes a test strategy rather than a test plan?

  • AThe overall approach: which testing methods will be used, in what order, by whom and when
  • BA numbered list of tests, each with its test data, its type and the expected result
  • CA record of the actual results obtained when each planned test was carried out
  • DThe set of boundary values chosen for each input that the program has to validate
Q21 mark

An input accepts a whole number of years from 18 to 65. Which value is abnormal test data?

  • A"thirty"
  • B18
  • C40
  • D65
Q31 mark

A bus fare function is being tested.

FUNCTION Fare(Age : INTEGER) RETURNS REAL
    IF Age < 16 THEN
        RETURN 2.50
    ELSE
        IF Age >= 60 THEN
            RETURN 1.00
        ELSE
            RETURN 4.00
        ENDIF
    ENDIF
ENDFUNCTION
Which test plan entry has the correct expected result?

  • AAge 16, expected result 4.00
  • BAge 15, expected result 4.00
  • CAge 60, expected result 4.00
  • DAge 16, expected result 2.50
Q41 mark

A school's attendance program works correctly. The school replaces its computers with touchscreen tablets, so the program is changed to accept touch input. Which type of maintenance is this?

  • AAdaptive
  • BCorrective
  • CPerfective
  • DAcceptance
Q51 mark

A password must be from 6 to 12 characters long. Which set of lengths tests both extreme values and the boundary at each limit?

  • A5, 6, 12, 13
  • B6, 7, 11, 12
  • C0, 6, 12, 20
  • D5, 7, 11, 13
Q61 mark

A shop amends a function so that members get 10% off orders of 20.00 or more.

FUNCTION Charge(Total : REAL, Member : BOOLEAN) RETURNS REAL
    IF Total > 20.00 AND Member = TRUE THEN
        RETURN Total * 0.9
    ENDIF
    RETURN Total
ENDFUNCTION
Which test from the test plan will reveal the error?

  • ATotal 20.00, Member TRUE, expected result 18.00
  • BTotal 25.00, Member TRUE, expected result 22.50
  • CTotal 20.00, Member FALSE, expected result 20.00
  • DTotal 15.00, Member TRUE, expected result 15.00
Quiz key
Q1: A

The test strategy sets out the overall approach: methods such as white-box, integration, alpha and acceptance testing, their order and who does them. A numbered list of tests with data and expected results is the test plan. Actual results are recorded when the plan is carried out. Boundary values are test data that go into the plan.

Q2: A

"thirty" is the wrong data type, so it must be rejected: abnormal (erroneous) data. 18 and 65 are extreme data, the smallest and largest values still accepted. 40 is normal data, a typical value that should be accepted.

Q3: A

16 < 16 is FALSE and 16 >= 60 is FALSE, so Fare(16) returns 4.00. Age 15 is below 16, so it returns 2.50, not 4.00. Age 60 satisfies >= 60, so it returns 1.00. Expecting 2.50 for 16 treats < as <=.

Q4: A

The program worked, but its environment (the hardware) changed, so it was adapted: adaptive maintenance. Corrective maintenance fixes errors, and there were none. Perfective maintenance improves a working program, such as making it faster, without any change in requirements or environment. Acceptance is a type of testing, not maintenance.

Q5: A

6 and 12 are the extreme values (accepted), and 5 and 13 are the first values rejected on each side, so 5, 6, 12, 13 covers every limit. 6, 7, 11, 12 contains only accepted lengths, so it never checks that anything is rejected. 0 and 20 are well outside the range (abnormal), not next to the limits. 5, 7, 11, 13 misses the extreme values 6 and 12.

Q6: A

For 20.00 with Member TRUE, 20.00 > 20.00 is FALSE, so the function returns 20.00 instead of the expected 18.00: the test fails and exposes the error (it should be >=). 25.00 for a member gives 22.50 as expected. A non-member is never discounted, and 15.00 is below the limit, so both of those tests pass and hide the error.

Lab and demo

What to project

The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.

Slides

Slides for this lesson

A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.

Also for this topic

Everything else you can use

Original work by the TheLucidSTEM team. The worksheet items are written in the style of the papers; no past paper question is reproduced.
Previous lessonTypes of error and testing methods