1 / 23

Defect testing

Defect testing. Testing programs to establish the presence of system defects. Test data and test cases. Test data Inputs which have been devised to test the system

Download Presentation

Defect testing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Defect testing • Testing programs to establish the presence of system defects

  2. Test data and test cases • Test data Inputs which have been devised to test the system • Test cases Inputs to test the system and the predicted outputs from these inputs if the system operates according to its specification

  3. Equivalence partitioning • Input data and output results often fall into different classes where all members of a class are related • Each of these classes is an equivalence partition where the program behaves in an equivalent way for each class member • Test cases should be chosen from each partition

  4. Equivalence partitioning • Partition system inputs and outputs into ‘equivalence sets’ • If input is a 5-digit integer between 10,000 and 99,999, equivalence partitions are <10,000, 10,000-99, 999 and > 10, 000 • Choose test cases at the boundary of these sets • 00000, 09999, 10000, 99999, 10001

  5. Structural testing • Sometime called white-box testing • Derivation of test cases according to program structure. Knowledge of the program is used to identify additional test cases • Objective is to exercise all program statements (not all path combinations)

  6. White-box testing

  7. Binary search (Java)

  8. Binary search - equiv. partitions • Pre-conditions satisfied, key element in array • Pre-conditions satisfied, key element not in array • Pre-conditions unsatisfied, key element in array • Pre-conditions unsatisfied, key element not in array • Input array has a single value • Input array has an even number of values • Input array has an odd number of values

  9. Binary search equiv. partitions

  10. Binary search - test cases

  11. Path testing • The objective of path testing is to ensure that the set of test cases is such that each path through the program is executed at least once • The starting point for path testing is a program flow graph that shows nodes representing program decisions and arcs representing the flow of control • Statements with conditions are therefore nodes in the flow graph

  12. Program flow graphs • Describes the program control flow. Each branch is shown as a separate path and loops are shown by arrows looping back to the loop condition node • Used as a basis for computing the cyclomatic complexity – a function of the number of distinct paths of execution within a module • Use graph theory to suggest a basis set of test

  13. Basic Control Constructs Sequence If-Then-Else While-Do Do-Until Case

  14. Cyclomatic complexity • The number of tests to test all control statements equals the cyclomatic complexity • Cyclomatic complexity equals number of conditions in a program • Useful if used with care. Does not imply adequacy of testing. • Although all paths are executed, all combinations of paths are not executed

  15. Binary search flow graph

  16. Independent paths • 1, 2, 3, 8, 9 • 1, 2, 3, 4, 6, 7, 2 • 1, 2, 3, 4, 5, 7, 2 • 1, 2, 3, 4, 6, 7, 2, 8, 9 • 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

  17. Graph Theory • The cyclomatic complexity, V(G) of a graph, G, with N vertices and E edges is V(G) = N – E + 2 • A predicate node is a node at which the path splits. If P is the number of predicate nodes, then V(G) = P + 1

  18. V(G) for Binary Search V(G) – the cyclomatic complexity for Binary Search = Nr Edges – Nr Nodes + 2 = 11 – 9 + 2 = 4 ----------------------------------------------- V(G) = Nr predicate nodes + 1 = 3 + 1 (nodes 2, 3 & 4) = 4

  19. More Graph Theory Euler’s Formula:If G is a connected plane graph (no edges crossing) with N vertices, E edges and R regions, then: N – E + R = 2, or equivalently R = E – N + 2 Since V(G) = E – N + 2, and R = E – N + 2, it follows that V(G) = R I.e. The cyclomatic complexity = the number of regions in the graph

  20. 1 2 3 4 Binary search flow graph

  21. Application to Testing • Associate a module with a graph with unique entry and exit nodes • Each node corresponds to a block of sequential code • Edges represent the program’s branches • Assumes each node can be reached from the entry node and each node can reach the exit node

  22. Application to Testing (cont’d) • The maximum number of independent paths in G is V(G). • V(G) represents the maximum number of test; not all of these tests may be possible

  23. General Notes • Cyclomatic Complexity has no direct relationship to the number of lines of code in a module • So, trying to limit complexity by limiting the number of lines of code is meaningless • Except when case statements are used, the cyclomatic complexity of a module should not exceed 10 • Studies show • 50% of the run time is spent in 4% of the code • For complexity < 5, conventional testing result in full coverage

More Related