
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

























The number of tests to test all control statements equals the cyclomatic complexity
Cyclomatic complexity equals number of conditions in a program plus one (or equivalently, in the program flow graph it is the “Number of edges - Number of nodes +2”)
Conditions are any type of branching operation such as each “if” statement or any types of loop (for, while etc.)
Useful if used with care. Does not imply adequacy of testing. Although all paths are executed, all combinations of paths are not executed
Binary search (Java)
class BinSearch { // This is an encapsulation of a binary search// ordered objects and a key and returns an object with 2 attributes namely function that takes an array of // index - the value of the array index// found - a boolean indicating whether or not the key is in the array //// reference to a function and so return An object is returned because two values it is not possible in Java to pass basic types by // the key is -1 if the element is not found public static void search ( int key, int [] elemArray, Result r ){ int bottom = 0 ;int top = elemArray.length - 1 ; int mid ;r.found = false ; r.index = -1 ; while ( bottom <= top ){ mid = (top + bottom) / 2 ;if (elemArray [mid] == key) { r.index = mid ; r.found = true ;return ; } // if partelse { if (elemArray [mid] < key) elsebottom = mid + 1 ; } top = mid - 1 ; } // search} //while loop } //BinSearch
Test cases should be derived so that all of these paths are executed
A dynamic program analyser may be used to check that paths have been executed
Integration testing - tests complete systems or subsystems composed of integrated components
Integration testing should be black-box testing with tests derived from the specification
Main difficulty is localising errors
Incremental integration testing reduces this problem
COMP201 - Software Engineering 7
docsity.com
Top-down testing
Start with high-level system and integrate from the top- down replacing individual components by stubs where appropriate
Bottom-up testing
Integrate individual components in levels until the complete system is created
In practice, most integration involves a combination of these strategies
Level N Level N Le vel N Level N Level N
Level N– 1 Level N– 1 Level N– 1
Testing sequence
Test drivers
Test drivers
Object-oriented systems – because these have a neat decomposition into classes and methods – makes testing easy
real-time systems – because we can identify slow bits of code more quickly
systems with strict performance requirements – because we can measure the performance of individual methods early in the testing process
Takes place when modules or sub-systems are integrated to create larger systems
Objectives are to detect faults due to interface errors or invalid assumptions about interfaces
Particularly important for object-oriented development as objects are defined by their interfaces
Test cases
A B
C
Interface misuse
A calling component calls another component and makes an error in its use of its interface e.g. parameters in the wrong order
Interface misunderstanding
A calling component embeds assumptions about the behaviour of the called component which are incorrect
Timing errors
The called and the calling component operate at different speeds and out-of-date information is accessed
Design tests so that parameters to a called procedure are at the extreme ends of their ranges
Always test pointer parameters with null pointers
Design tests which cause the component to fail
Use stress testing in message passing systems
In shared memory systems, vary the order in which components are activated
The components to be tested are object classes that are instantiated as objects
Larger grain than individual functions so approaches to white-box testing have to be extended
No obvious ‘top’ to the system for top-down integration and testing
Testing operations associated with objects
Testing object classes
Testing clusters of cooperating objects
Testing the complete OO system