Different Levels of Testing Unit Testing Functional Testing

  • Slides: 20
Download presentation
Different Levels of Testing Unit Testing Functional Testing System Component Testing Program unit A

Different Levels of Testing Unit Testing Functional Testing System Component Testing Program unit A Function 1 Program unit B. . . Component 1 Function 2. . . Component 3 Whole System (e. g. regression testing) Function 8 Program unit T Structural (white-box) testing more functional (Black-box) testing

Integration Testing • This is the step after the individual pieces of code or

Integration Testing • This is the step after the individual pieces of code or modules (programs) are tested. • A set of programs do not exist in vacuum. They are inter-related mostly in some manner through: – – Calling and passing controls Calling and passing data or passing “pointers” to data Object oriented relationship such as inheritance is addressed differently. • Integration test looks at the: 1. 2. 3. “structural” composition (or decomposition) and test the related code (modules / programs). The “call” relationship neighborhood and test the “neighborhood” The path created by the relationship and test the “path”

Types of Integration tests based on Structural Decomposition • There are 4 major types

Types of Integration tests based on Structural Decomposition • There are 4 major types of integration test for Structural Decomposition Based test: 1. 2. 3. 4. Top- down Bottom-up Combination (Sandwich) Big Bang

Top-down i) Once the root modules is “completed”, we need to build 3 stubs

Top-down i) Once the root modules is “completed”, we need to build 3 stubs to perform integration test of root module with stubs. ii) As the next level module is completed, we would build more stubs to perform the next level of integration test iii) Continue this process until all the completed modules are tested “completed” here means unit tested

Bottom-UP i) Once a set of bottom modules are completed we would build a

Bottom-UP i) Once a set of bottom modules are completed we would build a driver, at the next higher level, to run the integration test. ii) Continue this process until all the completed modules are tested

Combination (Sandwich) If this is completed first, we may choose to build 3 stubs

Combination (Sandwich) If this is completed first, we may choose to build 3 stubs to test - Once a module is completed, we would build the appropriate driver or stubs to perform the integration test. - Continue this process until all the modules are tested If these two are completed, we may choose to build a driver to test ; may also build two (green) stubs. “Combo” is a more likely scenario - - making “integration” management a complex job that needs some tool help.

Big-Bang - Wait for all the modules to be completed and perform one integration

Big-Bang - Wait for all the modules to be completed and perform one integration (one link-edit). Then test all the integrated modules together. This scenario happens more likely at the over-all system or component test time

Some Metrics for Integration Test based on Structural Decomposition • For Top-down approach with

Some Metrics for Integration Test based on Structural Decomposition • For Top-down approach with n nodes, there is a potential need to construct as much as (n-1) stubs. • For Bottom-up approach with n nodes and v leaves, there is a potential need to construct as much as (n- v) drivers. • For both cases there may be as much as (n – v + edges) number of test sessions (e. g. cases or scenarios)

Simple Construct Example for the Metrics A B C • There are 5 nodes

Simple Construct Example for the Metrics A B C • There are 5 nodes and 4 leaves and 4 edges: 1. 2. 3. n- 1 = 5 -1 = 4 stubs n - v = 5 - 4 = 1 driver n - v+ edges = 5 - 4 + 4 = 5 test sessions D E Number of test sessions = 5: (Top-down) 1. A is complete: test with 4 stubs (Bottom-up) E is complete: test with driver A 2. B is complete: test with 3 stubs D is complete: test with driver A 3. C is complete: test with 2 stubs C is complete: test with driver A 4. D is complete: test with 1 stub B is complete: test with driver A 5. E is complete: test all modules A is complete: test all modules

Slightly Modified Example for the Metrics A B C E D Number of test

Slightly Modified Example for the Metrics A B C E D Number of test sessions = 6: (Top-down) 1. A is complete: test with 2 stubs (Bottom-up) E is complete: test with driver A • There are 5 nodes and 3 leaves and 4 edges: 2. B is complete: test with 2 stubs D is complete: test with driver B 1. 2. 3. n- 1 = 5 -1 = 4 stubs n - v = 5 - 3 = 2 drivers n - v+ edges = 5 – 3 + 4 = 6 test sessions 3. B is complete: test with A C is complete: test with driver B 4. C is complete: test with B B is complete: test with C and D 5. D is complete: test with B B is complete: test with driver A 6. E is complete: test all modules A is complete: test all modules

Pair-Wise Integration (Sandwich-like) • One of the key drawbacks to top-down or bottom-up testing

Pair-Wise Integration (Sandwich-like) • One of the key drawbacks to top-down or bottom-up testing for Decomposition-based integration testing is the need for constructing drivers and stub. • Pair wise integration testing waits for a “related pair” of modules to be completed and then test them. Thus it eliminates the stubs and drivers. There is also a potential reduction in test sessions (# of edges). . “Related” via edge connection

Example of Pair-wise Testing A A B C E B C D E D

Example of Pair-wise Testing A A B C E B C D E D Pair-wise test sessions : 4 1. 2. 3. 4. A–B B–C B–D A–E A–B A–C A–D A–E

“Neighborhood” Integration Testing • Neighborhood of a node is the set of nodes that

“Neighborhood” Integration Testing • Neighborhood of a node is the set of nodes that are one edge away from the given node. – Thus the neighborhood of a node, n, are all the predecessors and successor nodes of n. – # of neighborhoods = # of interior nodes + source node. • There are some positive and negative characteristics with neighborhood integration testing: – Positives: • Less test sessions • ** Possibly give more of a “behavior” view of a “thread” – Negative: • May be harder to locate bugs • Wait for the completion (timing) of a neighborhood before testing

Number of “neighborhoods” • Number of neighborhoods in a call graph may be viewed

Number of “neighborhoods” • Number of neighborhoods in a call graph may be viewed as: – Number of interior nodes (that form neighborhoods around them) and – 1 neighborhood around the root node • Numerically: – Interior nodes = all nodes – ( source node + sink nodes) – # of Neighborhood = interior nodes + source node – # of Neighborhood = all nodes – sink nodes Note that source node is the 1 root-node in our case: - we should start with the neighborhood around the root - then consider all the neighborhoods around the interior nodes

Example of Neighborhood Integration Testing A A B C E B C D E

Example of Neighborhood Integration Testing A A B C E B C D E D Total nodes = 5 Sink nodes = 3 Total nodes = 5 Sink nodes = 4 Neighborhood = 5 – 3 = 2 Neighborhood = 5 - 4 = 1 A A A B B E neighborhood(1) C D neighborhood (2) B C D (1) neighborhood E

How many neighborhoods are there? A B E I C F G D H

How many neighborhoods are there? A B E I C F G D H J There are ( 10 nodes – 5 sink nodes) = 5 neighborhoods - 1 around the root (start here --- so there is some potential wait time) - 1 around B - 1 around E - 1 around C - 1 around D

Path Based Integration Test • Instead of just focusing on the interfaces of the

Path Based Integration Test • Instead of just focusing on the interfaces of the “related” modules in integration test, it would be more meaningful to also focus on the “interactions” among these related modules. • An extension of the neighborhood would be to trace a complete “thread” of interactions among the modules and test that “thread” or “path. ”

Some Definitions for Path-based Integration Test • Source node is the point where program

Some Definitions for Path-based Integration Test • Source node is the point where program execution starts • Sink node is the point where the program execution stops • A module execution path is a sequence of statements that begins with a source node and ends with a sink node, with no intervening sink nodes. • A message is a “mechanism” with which one unit of code transfers control to another unit of code; control return is also a message • An MM-path (module-to-module path) is an interleaved sequence of i) module execution paths and ii) messages – Sequence of “nodes” represent a module execution path – Sequence of “edges” represent the messages • An MM-Path Graph is the directed graph in which nodes are from the module execution paths and edges are passing of control/messages.

A Simple Example of an MM-Path (Module A) 1 (Module B) (Module C) 1

A Simple Example of an MM-Path (Module A) 1 (Module B) (Module C) 1 1 2 3 4 2 5 3 4 4 5 Source nodes : B 1 and B 3 Sink nodes: B 2 and B 4 Source nodes : C 1 Sink nodes: C 5 6 Source nodes : A 1 and A 5 Sink nodes: A 4 and A 6 A 1= <1, 2, 3, 6>; A 2=<1, 2, 4> ; A 3 = <5, 6> Module Execution Paths: B 1= <1, 2> ; B 2 = <3, 4> C 1= <1, 2, 4, 5> ; C 2= <1, 3, 4, 5> Note: Should modules A and B be recoded ?

Simple Example of MM-Path Graph (from previous slide) A 2 B 1 A 1

Simple Example of MM-Path Graph (from previous slide) A 2 B 1 A 1 C 1 B 2 C 2 A 3 - The MM-Path that goes across modules may be looked upon as an inter-module “slice. ” - In large and medium sized systems, an MM-Path may be viewed as a “major application function/thread”.