0% found this document useful (0 votes)
117 views19 pages

2.4.3 Testing Strategies

The document contains test data examples for validating different program modules. 1) It provides three pairs of numbers as test data for a module that outputs the larger of two input numbers, and explains what each pair intends to test. 2) It asks for four test data items and reasons to validate a JobID between 1-1000, to test the validation logic for that module. 3) It asks for five sets of test data with reasons to test a module that calculates employee hours and pay, testing different input/output scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views19 pages

2.4.3 Testing Strategies

The document contains test data examples for validating different program modules. 1) It provides three pairs of numbers as test data for a module that outputs the larger of two input numbers, and explains what each pair intends to test. 2) It asks for four test data items and reasons to validate a JobID between 1-1000, to test the validation logic for that module. 3) It asks for five sets of test data with reasons to test a module that calculates employee hours and pay, testing different input/output scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

May/June 2002

3. An algorithm has been produced which inputs two numerical values and outputs the larger one.

Select three pairs of numbers that could be used as test data. Explain what each pair of numbers is intended to test.

[6]

May/June 2004

3. (c) A program has been written using a top-down technique.

The individual modules in the program have been fully tested and there are no errors in any of them.

Explain why the program may fail to run or may produce incorrect results, despite the testing that has been done. [2]

May/June 2007

6. D=1

INPUT X, E

B=E

C=E

FOR I = 1 TO (X-1)

INPUT A

IF A>B THEN B = A

ELSE IF A < C THEN C = A

END IF

END IF

D = D + 1

E = E + A

NEXT

F = E/D

OUTPUT B, C, F

END

(b) Give three other different sets of test data, explaining what condition each is meant to test. [3]
Page 1 of 19
Computer Science 9608
Topical Past Papers

May/June 2011. P21/P22

1 Ahmed, a designer, stores the following details of each job that he does in a file.

• job ID (a whole number between 1 and 1000 inclusive)


• job description
• price (greater than $10 and not more than $5000)
• expected completion date
• paid (yes/no)

(f) The code for the validation will have to be tested.

State four items of data you would use to test the JobID validation.

State the reasons for using that test data.

[8]

May/June 2011. P23

3 Kris has written a program that will work out the wages for her staff. The main steps for each employee are: to
work out the hours worked, work out the total earnings, work out tax and finally print out how much will be taken
home.

For each employee the hours worked module collects data for five days. If they do not work on a particular day a
zero is entered. Each person can work up to 9 hours a day for up to 5 days a week. The hours are added up; no-one
may work more than 40 hours.

Write five sets of test data which test the module for different inputs/outcomes.

For each set of test data, give a reason for your choice.

Page 2 of 19
[10]

Oct/NOV 2011. P21

2 Nathan is designing a software solution for stock control in a mobile phone shop. He has a colleague, called Andre,
who will help him write the program. Nathan decides to modularise the solution.

(g) One type of test data is invalid data.

(i) Name the other two types. [2]


(ii) Andre has written the StockOrdering module, which now needs testing.
 The StockID is a whole number between 1000 and 9999
 The ReOrderLevel is between 10% and 20%
Give six different items of test data, other than invalid data, which thoroughly test the two rules given
above. Give a reason for each choice. [6]

Page 3 of 19
Oct/NOV 2011 P22

1 (g) One type of test data is invalid data.

(ii) Nathan has written the PhoneSales module, which now needs testing.

• ContractLength, the number of months of the contract, can be only 12, 18 or 24


• FreeTexts, the number of free text messages per month must be in the range 0 to 600

Give six different items of test data other than invalid data which thoroughly test the two rules given above. Give a
reason for each choice.

[6]

Page 4 of 19
Oct/NOV 2011 P23

1 Nathan is designing a software solution for stock control in a computer shop. He has a colleague, called Andre, who
will help him write the program. Nathan decides to modularise the solution.

(g) One type of test data is invalid data.

(i) Name the other two types. [2]


(ii) Andre has written the Sales module, which now needs testing.
• InvoiceNumber has the format yy-nnnn e.g. 11-0035 is the 35th invoice of the year 2011
• PromotionCode can be 'gold', 'silver' or 'bronze' only

Give six different items of test data, other than invalid data, which thoroughly test the two rules given
above. Give a reason for each choice.

[6]

Page 5 of 19
May/June 2013. P21/22

2 The data for each record is validated as it is entered.

(c) (i) Meena uses three items of data to test this logic. In the table below enter ‘normal’ or ‘borderline’ in the empty
cells.

(ii) State the reason why this invalid HandInDate is not a good test of the validation rules. [1]

(iii) State three hand-in dates that provide a better test to show that invalid data does not get entered. [3]

Oct/Nov 2013. P22

1 Jemma is designing a program that will work out the end of year bonuses for her employees. The main steps are:

• input employee's data


• calculate the bonus
• calculate deductions
o tax
o optional contribution to charity
• print out the bonus

(d) Jemma is designing a range validation check for the input of an employee’s pay. The pay range depends on the
employee’s job type, which may be P(part-time), F(full-time) or C(commission only).

• A part-time employee will earn between $100 and $10000 a year.


• A full-time employee will earn between $5000 and $50000 a year.
• A commission only employee will earn between $0 and $80000 a year.

Complete the table showing five more rows of test data. Give a different reason for each, describing what is being
tested.

Page 6 of 19
[5]

Oct/Nov 2014.P21/P23

1 Rema surveys the students in her class to find out which is the most popular sport.

She draws a tally chart:

Rema plans to collect sport data from students in the whole school. She designs a program to:

• input the number of the sport a student likes best (1, 2, 3 or 4)


• repeatedly ask for input until the input is 0 (zero)
• keep a count of each choice
• on completion of data entry, print out the results as a tally chart (as shown above)

Rema’s first attempt is the following pseudocode:

Page 7 of 19
Cricket ← 0

Football ← 0

Tennis ← 0

Swimming ← 0

REPEAT

INPUT Choice

CASE Choice OF

1: Cricket ← Cricket + 1

2: Football ← Football + 1

3: Tennis ← Tennis + 1

4: Swimming ← Swimming + 1

ENDCASE

UNTIL Choice = 0

OUTPUT "Cricket ", Cricket

OUTPUT "Football ", Football

OUTPUT "Tennis ", Tennis

OUTPUT "Swimming ", Swimming

Her friend Aisha suggests that the pseudocode could be improved by:

• using a one-dimensional array, Tally, instead of four variables to store the counts
• modularising the design. The main program should just consist of three procedure calls:
InitialiseArrayCounts
InputStudentChoices
OutputTallyChart

(d) Rema wants to test each module before she tests the whole program.

The first module she is going to test is the OutputTally procedure using different parameter values.

Give three different types of test data with an example of each.

Justify your choices.

Page 8 of 19
[9]

Oct/Nov 2014.P22

3 A game is played by two players. Player A uses white tokens ( ). Player B uses black tokens ( ). The players
take turns dropping tokens into a vertical grid. The tokens fall straight down and occupy the next available space in
the chosen column. The aim of the game is to connect four of one’s own colour tokens. This must be done in a
vertical, horizontal or diagonal line.

Here is one example after Player A has had 2 turns and Player B has had 1 turn:

Nathan wants to write a program to allow two users to play the game on the computer.

The program will display a simplified version of the above grid which is redrawn after every turn.

(c) To drop a token into the grid, the player enters the chosen column number.

The function ColumnNumberValid has a parameter (x) which is the chosen column number. The function
returns:

• TRUE if x is between 1 and 7 inclusive and there is still space in the column

• FALSE otherwise

Page 9 of 19
(ii) Nathan wants to test the validation of the parameter, x, by this function.

Give three different types of test data with an example of each.

Justify your choices

[9]

May/June 2015.P21/P22

3 A board game is designed for two players, O and X.

At the beginning, all cells of a 3 x 3 grid are empty.

The players take turns in placing their marker in an empty cell of the grid; player O always starts.

The game ends when one player completes a row, column or diagonal or the grid is full.

Here is one example after three turns:

Ali wants to write a program to play the game.

(b) Ali decides to validate the player input.

The input is valid if:

• the row and column numbers are within the range 1 to 3 inclusive
• the cell is empty

Page 10 of 19
Ali chooses a sequence of six pairs of integer values to simulate player input. The test starts with an empty grid.

(i) Show the contents of the grid after the input of each pair of integer values. Circle whether the input is
valid or invalid. If the input is invalid state the reason.

[6]

(h) When Ali has tested all individual modules he plans to do further testing.

Give two types of testing Ali should do. [2]

Page 11 of 19
May/June 2015.P23

4 A leap year is a year with special numerical properties.

Ahmed is planning to write a function to check whether a year is a leap year.

He starts by drawing a flowchart.

(b) Ahmed wants to carry out white box testing of the function.

Give four integers which thoroughly test the function. For each one, give the expected return value and justify your
choice.

Page 12 of 19
[4]

(c) When Ahmed has tested the function, he plans to use it in a program.

Give two types of testing that Ahmed could do with the completed program. [2]

Oct/Nov 2015.P21/P23

2 Alia received a number coded as a sequence of letters. She wants to write a program to change this sequence of
letters back to the original number. She knows that each digit of the original number was replaced by exactly one
letter. The letters used are shown in the flowchart below.
She has drawn the flowchart as part of the design for her solution.
The function DenaryDigit(Letter) returns an integer.

Page 13 of 19
(a) (ii) Alia needs to test this function before using it in her program.
Complete the table of test data.

[3]

Page 14 of 19
Oct/Nov 2015.P22

2 At the end of movies, when credits are listed, the year of production is often shown in Roman
numerals.
Roman numbers are formed by combining letters together and adding their value. The letters used
and their values are:

M: 1000
D: 500
C: 100
L: 50
X: 10
V: 5
I: 1
For example, MMXV is 1000 + 1000 + 10 + 5 = 2015.
Ali wants to write a program to convert a year written in Roman numerals to denary.
He has drawn the flowchart as part of the design for his solution.

(a) (ii) Ali needs to test this function before using it in his program.
Complete the table of test data.

Page 15 of 19
[3]

(d) The order of letters in Roman numbers is significant. Letters are placed from left to right, in
order of value, starting with the largest.
However, a sequence of four identical letters (such as IIII) is shortened as follows.
If a letter to the left is of lower value than the letter to its right, the left letter’s value becomes
negative.
Examples are shown in the following table:

Ali has to amend his pseudocode to include the conversion of these shortened Roman
numbers.
Ali has chosen some test data.
Complete the table.

[4]
Page 16 of 19
Computer Science (9608)
May/June 2015.P21/P22

1 A marathon runner records their time for a race in hours, minutes and seconds.

An algorithm is shown below in structured English.

INPUT race time as hours, minutes and seconds

CALCULATE race time in seconds

STORE race time in seconds

OUTPUT race time in seconds

(c) The program code will be tested using white-box testing.

(i) Explain what is meant by white-box testing. [2]


(ii) Complete the table heading.
Complete Test Number 1.
Add the data for Test Number 2 and Test Number 3.

[6]

Oct/Nov 2015.P21/P23

3 A program is to simulate the operation of a particular type of logic gate.


• The gate has two inputs (TRUE or FALSE) which are entered by the user.
• The program will display the output (TRUE or FALSE) from the gate.
The program uses the following identifiers in the pseudocode below:

Page 17 of 19
01 INPUT InA
02 INPUT InB
03 IF (InA = FALSE AND InB = FALSE) OR (InA = FALSE AND InB = TRUE)
OR (InA = TRUE AND InB = FALSE)
04 THEN
05 OutZ ← TRUE
06 ELSE
07 OutZ ← FALSE
08 ENDIF
09 OUTPUT OutZ
(a) The programmer chooses the following four test cases.
Show the output (OutZ) expected for each test case.

[4]

Oct/Nov 2015.P22

2 A program is to simulate the operation of a particular type of logic gate.


• The gate has two inputs (0 or 1) which are entered by the user.
• The program will display the output (0 or 1) from the gate.
The program uses the following identifiers in the pseudocode below:

01 INPUT P
02 INPUT Q
Page 18 of 19
03 IF (P = 1 AND Q = 0) OR (P = 0 AND Q = 1) OR (P = 0 AND Q = 0)
04 THEN
05 X ← 0
06 ELSE
07 X ← 1
08 ENDIF
09 OUTPUT X
(a) The programmer chooses the following four test cases.
Show the output (X) for each test case.

[4]

Page 19 of 19

You might also like