|
1. CAUSES OF ERROR |
Broadly we can identify 3 causes of error:
|
Consider the following program fragment where a "divide by zero" may be caused to occur. public int division(int xValue, yValue) { int zValue; zValue = xvalue/yValue; return(zValue); } If the variable yValue is set to 0 a "divide by zero" error will occur. |
2. CLASSIFICATION OF ERRORS |
There are various methods whereby commonly experienced errors can be classified. These can be summarised as follows.
|
|
3. SOFTWARE TESTING |
Software testing is an essential element of the software development process. The objectives of software testing may be stated as follows (Myers 1979):
|
Remember that if no errors are discovered we cannot say that "the software in question is error free", all we can say is that "no errors have been discovered". |
4. VERIFICATION AND VALIDATION (V&V) |
We can identify two distinct elements of software testing:
Verification refers to the set of activities that ensures that software is correctly implemented as a set of methods. |
Validation refers to a different set of activities that ensures that the software built is traceable to customer requirements. The distinction is sometimes described as follows (Bohem 1981):
|
5. TEST CASES |
Both parts of V&V can be carried out using appropriate test cases. Over the past two decades (sinse 2002) a rich variety of test case design methods have evolved for software. These methods provide the developer with a systematic approach to testing. |
More importantly, they provide a mechanism that can help to ensure the completeness of tests and provide the highest likelihood for uncovering errors in software. We can identify two types of testing:
|
Black box testing is concerned with inputs to, and outputs from, software. Black box test cases are designed to demonstrate that :
|
Black box testing is not concerned with the internal operation of a software system only its interface activities. |
White box testing is concerned with the internal operation of software systems. Logical paths through the software are tested by providing test cases that exercise specific sets of conditions and/or loops. In addition the "status of the program" may be examined at various points to determine if the expected or asserted status corresponds to the actual status. The latter is normally carried out during the implementation process rather than subsequent to it. |
Typically test cases are generated to:
|
6. BLACK BOX TESTING TECHNIQUES |
Limit testingGiven an input variable of some form we should derive test cases that include the lowest and highest possible values for the variable in question. Boundary Value Analysis (BVA) testingFor reasons that are not completely clear a greater number of errors tend to occur at the boundaries of the input domain rather than in the centre. It is for this reason that Boundary Value Analysis (BVA) has been developed as a testing technique. BVA leads to a selection of test cases that exercise bounding values. Guidelines for BVA are as follows: |
Arithmetic testingArithmetic testing is only applicable for statements that incorporate arithmetic expressions. In this case test cases should be constructed whereby each variable in the expression is tested with a zero, negative and positive sample value (if the variable's definition permits this) against each other variable (also with a zero, negative and positive sample values). |
7. WHITE BOX TESTING TECHNIQUES |
Whit box (glass box) testing is concerned with the internal operation of software. Path TestingThis is concerned with the derivation of a set of test cases to exercise every statement in a program at least once during testing. Before appropriate test cases can be derived we must know how control may flow through our program. Their are specialised notations which may be used for this. We have been using Activity Diagrams (ADs). Loop testingLoop testing is a white box testing technique that focuses exclusively on the validity of loop constructs (suggested by Beizer amongst others in the early 1980s - Beizer 1983). In addition to testing each path within a loop a specialised set of additional tests are recommended depending on the type of loop:
|
|
7.1. Loop testing exampleAn example variable count loop is given in Table 1. Note that the number of itterations for this loop is influenced by the value of the input data item. However, N (the maximum passes through the loop) is 10. A suitable set of loop test cases for this code is given to the right. |
|
// LOOP TESTING EXAMPLE PROGRAM // Frans Coenen // Wednesday 20 August 2003 // The University of Liverpool, UK import java.io.*; class LoopTestExampleApp { // ------------------ FIELDS ------------------------ public static BufferedReader keyboardInput = new BufferedReader(new InputStreamReader(System.in)); private static final int MINIMUM = 1; private static final int MAXIMUM = 10; // ------------------ METHODS ------------------------ /* Main method */ public static void main(String[] args) throws IOException { System.out.println("Input an integer value:"); int input = new Integer(keyboardInput.readLine()).intValue(); int numberOfIterations=0; for(int index=input;index >= MINIMUM && index <= MAXIMUM;index++) { numberOfIterations++; } // Output and end System.out.println("Number of iterations = " + numberOfIterations); } } |
Table 1: Variable count loop (number of iterations depends on input value)
8. DATA VALIDATION |
Data validation is concerned with the input of spurious data to ensure that our program cam successfully handle such input. The exceptions handling mechanism that comes with Java is very good at "catching" such erroneous input so we do not normally have to include any additional code to handle this.
9. UNIT AND SYSTEM TESTING |
When writing significant software systems (in terms of size) it is often not practical (or desirable) to leave all testing till completion of the entire software system --- this is not considered to be good practice. Instead we should test individual methods, or small groups of methods that are intended to perform some particular function, as the implementation proceeds. We refer to this type of testing as Unit Testing. Once the software system is complete we will still have to test the operation of the entire system; but, because we have carried out our unit testing, we will know that the individual components are working correctly. This testing of the entire ststem on completion is refered to as System Testing.
Note that Top down development can easily be combined with unit testing.
10. DEBUGGING |
Debugging occurs as a consequence of successful testing, i.e. when an error is discovered. Debugging is a four stage process:
|
Note that the last three stages are analogous to the stages in the software development process. Error location can be the most arduous stage in this process. The most straightforward and simplest method of locating the source of errors is through code inspections. If this fails output statements may be embedded in the code whereby values for key variables or messages are output (the latter indicating that specific stages in the processing have been reached). In this manner, through a process of elimination, sources of errors can be isolated. Tools (called debuggers) exist to help software developers to debug software. |
Created and maintained by Frans Coenen. Last updated 10 February 2015