0% found this document useful (0 votes)
12 views4 pages

Program Testing Strategies Explained

The document discusses program testing strategies, including black-box and white-box testing, and the importance of identifying syntax, logic, and run-time errors. It emphasizes the need for careful testing to uncover difficult-to-find errors and introduces stub testing as a method for testing user interfaces before full implementation. The document also highlights the role of test data in validating program functionality and the process of dry-running algorithms to ensure correctness.

Uploaded by

chiyanjapeter7
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)
12 views4 pages

Program Testing Strategies Explained

The document discusses program testing strategies, including black-box and white-box testing, and the importance of identifying syntax, logic, and run-time errors. It emphasizes the need for careful testing to uncover difficult-to-find errors and introduces stub testing as a method for testing user interfaces before full implementation. The document also highlights the role of test data in validating program functionality and the process of dry-running algorithms to ensure correctness.

Uploaded by

chiyanjapeter7
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

Paper 2. Sec 2.4.

3) Program Testing Strategies Computer Science 9608


with Majid Tahir

Syllabus Content:
2.4.3 Program testing strategies:
choose suitable data for black-box testing
choose suitable data for white-box testing
understand the need for stub testing

Testing strategies
Finding syntax errors is easy. The compiler/ interpreter will find them for you and usually gives
you a hint as to what is wrong.

Syntax Error:
A syntax error is a 'grammatical' error, in which a program statement does not follow the rules
of the high-level language constructs.

When Syntax error occurs, VB IDE underlines


wrong syntax, and gives options for corrections.

Much more difficult to find are logic errors and run-time errors.

1
Paper 2. Sec 2.4.3) Program Testing Strategies Computer Science 9608
with Majid Tahir

A run -time error occurs when program execution comes to an unexpected ha lt or 'crash' or it
goes into an infinite loop and 'freezes'.

Logical Error:
Logic error: an error in the logic of the solution that causes it not to behave as intended

Run-time Error:
Run-time error: an error that causes program execution to crash or freeze

Testing
Both of these types of errors can only be found by careful testing. The danger of such errors is
that they may only manifest themselves under certain circumstances. If a program crashes
every time it is executed, it is obvious
there is an error.

If the program is used frequently and


appears to work until a certain set of
data causes a malfunction.

That is much more difficult to discover


without perhaps serious
consequences.

Stub testing
When you develop a user interface,
you may wish to test it before you
have implemented all the facilities.

You can write a 'stub' for each


procedure (see Figure).

The procedure body only contains an


output statement to acknowledge that
the call was made.
Each option the user chooses in the
main program will call the relevant
procedure.

2
Paper 2. Sec 2.4.3) Program Testing Strategies Computer Science 9608
with Majid Tahir

Black-box Testing:
As the programmer, you can see your program code and your testing will involve knowledge of
the code (see the next section, about white-box testing).

As part of thorough testing, a program should also be tested by other people, who do not see
the program code and don't know how the solution was coded.

Such program testers will look at the program specification to see what the program is meant to
do, devise test data and work out expected results.

Test data usually consists of normal data values, boundary data values and erroneous data
values.

The tester then runs the program with the test data and records their results. This method of
testing is called black-box testing because the tester can't see inside the program code: the
program is a 'black box'.

Where the actual results don't match the expected results, a problem exists. This needs further
investigation by the programmer to find the reason for this discrepancy and correct the program.

Once black-box testing has established that there is an error, other methods have to be
employed to find the lines of code that need correcting.

White-box Testing:
How can we check that code works correctly? We choose suitable test data that checks every
path through the code

Dry-running an algorithm:
A good way of checking that an algorithm works as intended is to dry-run the algorithm using a
trace table and different test data.
The idea is to write down the current contents of all variables and conditional values at each
step of the algorithm.

3
Paper 2. Sec 2.4.3) Program Testing Strategies Computer Science 9608
with Majid Tahir

References:
Cambridge International AS & A level Computer Science Course book by Sylvia Langfield and Dave Duddell
Visual Basics Console Mode Editor Window from notes of Sir Majid Tahir

You might also like