Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Testing

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

12.

3 Program Testing and maintenance

What is program fault?


 A program fault is something that makes the program not do what it is supposed to do
under certain circumstances

Note:
 Faults or bugs in a program are then exposed at the testing stage.
 Testing will show the presence of faults to be corrected, but cannot guarantee that large,
complex programs are fault free under all circumstances.
 Faults can appear during the lifetime of a program and may be exposed during live
running.
 The faults are then corrected as part of the maintenance stage of the program lifecycle

Different types of errors


Syntax error
 Syntax errors are errors in the grammar of a source program// occurs due to the
grammatical mistakes in the program.
 In the coding phase of the program development lifecycle, programs are either compiled
or interpreted so they can be executed.
 During this operation, the syntax of the program is checked, and errors need to be
corrected before the program can be executed.

 The above shows an example of a syntax error being found, and the IDE offering a
possible reason for the error.
 Many IDEs will offer suggestions about what syntax errors are and how to correct them.
 Mistyping or misspelled a reserved word such as writing PLINT instead on PRINT. Such
errors cause a halt in the translation process
 not closing an opened bracket e.g y = 10 / (2+
 no THEN keyword used in visual basic in IF statements e.g IF x > 10
 using NEXT without FOR

State when and how syntax errors are detected


When: during compilation/interpretation/while code is written in an IDE
How: the compiler/interpreter/IDE checks that the rules of the language are being followed

2. Logic errors
 Logic error is a mistake in the structure of a program (mistake occurs because the
algorithm on which the code is based is faulty) e.g using + instead of –
 An error in the algorithm that causes the program not to behave as intended
 This programming error is not detected by the computer but can only be identified
through the results the program produces.
 Error messages are not produced.

Examples:
Writing Net salary = Gross pay + Deductions instead of
Net salary = Gross pay - Deductions
Other examples:
having 3 iterations instead of 4
jump to a wrong point in the program
Consequently, such errors do not halt the translation process
When and how logic errors are identified?
 When: when unexpected results occur
 How: Using tools such as a trace table// dry run // white box

 Trace tables show the process of dry-running a program with columns showing the values of
each variable as it changes.

Run time error


 Run-time errors happen when the program is executed.
 The program may halt unexpectedly or go into an infinite loop and need to be stopped by
brute force.
 A program performs an invalid operation / tries to divide by zero // enters an infinite loop
/ stops unexpectedly
 If a program is being tested in an IDE, then this type of error may be managed, and a
suitable error message given, as shown below.

Note:
 Programs need to be rigorously tested before they are released.
 There needs to be a test strategy set out in the analysis stage of the program development
lifecycle showing an overview of the testing required to meet the requirements specified.
 This shows how and when the program is to be tested.
 In order to clarify what tests need to be performed, a test plan is drawn up showing all the
stages of testing and every test that will be performed.
 As the testing is carried out, the results of the tests can be added to the plan showing that
the program has met its requirements.
 There are several formal methods of testing used to ensure that a program is robust and
works to the standard required. Although there is a testing stage in the program
development lifecycle, testing in some form occurs at every stage, from design to
maintenance.
Methods of testing
Dry run: in which the developer works through a program or module from a program manually
and documents the results using a trace table.

Walkthrough:
 A formalised version of a dry run using pre-defined test cases.
 This is where another member of the development team independently dry runs the
pseudocode, or the developer takes the team members through the dry run process.
 This is often done as a demonstration.
 During the program development and testing, each module is tested as set out in the test
plan. Test plans are often set out as a table; an example for the calculation procedure is
shown below.

Types of test data

Types of testing
White box testing
 It is the detailed testing of how each procedure works.
 It involves testing the structure and logic of every path through a program module.
Black box testing
 involves checking whether the output is as expected for a given input without knowing
the code (check if expected data = actual data).
Note:
 A software testing technique whereby the internal workings of the item being tested are
not known by the tester.
 For example, in a black box test on a software design the tester only knows the inputs and
what the expected outcomes should be and not how the program arrives at those outputs.
 The tester does not ever examine the programming code and does not need any further
knowledge of the program other than its specifications.

Integration testing
 Testing of any separately written modules to ensure that they work together during the
testing phase of the program development lifecycle.
 If any of the modules have not been written yet, stub testing can be included which
makes use of dummy modules for testing purposes.

After program has been written it is tested as a whole:


 Alpha testing is used first. The completed or nearly completed program is tested in-house
by the development team
 Beta testing is then used. The completed program is tested by a small group of users
before it is generally released.
 Acceptance testing is then used for the completed program to prove to the customer that
it works as required in the environment in which it will be used.

You might also like