ppt

25
Software Engineering – Software Testing Techniques Techniques FUNDAMENTALS FUNDAMENTALS The goal of testing is to find errors. The goal of testing is to find errors. A good test is one that has a high probability of finding an error. A good test is one that has a high probability of finding an error. A good test is not redundant A good test is not redundant A good test should be neither too simple nor to complex. A good test should be neither too simple nor to complex.

Upload: softwarecentral

Post on 18-Nov-2014

6.753 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

FUNDAMENTALSFUNDAMENTALS

The goal of testing is to find errors.The goal of testing is to find errors.

A good test is one that has a high probability of finding an error.A good test is one that has a high probability of finding an error.

A good test is not redundantA good test is not redundant

A good test should be neither too simple nor to complex.A good test should be neither too simple nor to complex.

Page 2: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BLACK BOX AND WHITE BOX TESTINGBLACK BOX AND WHITE BOX TESTING

One can test an engineered product by:One can test an engineered product by:

1.1. Knowing the specified function that a product was designed to perform.Knowing the specified function that a product was designed to perform.

2.2. Knowing the internal workings of a productKnowing the internal workings of a product

Black box testing alludes to tests that are conducted at the software interface.Black box testing alludes to tests that are conducted at the software interface.

A black box test examines some fundamental aspect of a system with little regard for A black box test examines some fundamental aspect of a system with little regard for the internal structure of the software.the internal structure of the software.

White-box testing of software is predicated on close examination of procedural detail.White-box testing of software is predicated on close examination of procedural detail.

Logical paths through the software and collaborations between components are tested Logical paths through the software and collaborations between components are tested by providing test cases that exercise specific sets of conditions and/or loops.by providing test cases that exercise specific sets of conditions and/or loops.

Page 3: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BLACK BOX AND WHITE BOX TESTINGBLACK BOX AND WHITE BOX TESTING

White box testing is sometimes called glass box testing.White box testing is sometimes called glass box testing.

White box testing uses the control structure described as part of the component level White box testing uses the control structure described as part of the component level design to derive test cases. design to derive test cases.

Using white box testing methods, the software engineer can derive test cases that:Using white box testing methods, the software engineer can derive test cases that:

1.1. guarantee that all independent paths within a module have been exercised at guarantee that all independent paths within a module have been exercised at least once.least once.

2.2. exercise all logical decisions on their true and false sides.exercise all logical decisions on their true and false sides.

3.3. execute all loops at their boundaries and within their operational boundsexecute all loops at their boundaries and within their operational bounds

4.4. exercise internal data structures to ensure their validity.exercise internal data structures to ensure their validity.

Page 4: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

The basis path method enables the test case designer to derive a logical complexity The basis path method enables the test case designer to derive a logical complexity measure of a procedural design and use this measure as a guide for defining a measure of a procedural design and use this measure as a guide for defining a basis set of execution paths.basis set of execution paths.

Test cases derived to exercise the basis set are guaranteed to execute every statement Test cases derived to exercise the basis set are guaranteed to execute every statement in the program at least one time during testing.in the program at least one time during testing.

Page 5: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

FLOW GRAPH NOTATIONFLOW GRAPH NOTATION

A flow graph depicts logical control flow using the notation shown below:A flow graph depicts logical control flow using the notation shown below:

Each structured construct corresponds to a flow graph symbol.Each structured construct corresponds to a flow graph symbol.

Page 6: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

Flow charts and flow graphs correspond to one another.Flow charts and flow graphs correspond to one another.

The flow chart depicts the program control structure.The flow chart depicts the program control structure.

The flow graph assumes no compound structures.The flow graph assumes no compound structures.

Page 7: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

Flow charts and flow graphs correspond to one another.Flow charts and flow graphs correspond to one another.

Each circle, called a flow graph node, represents one or more procedural statements.Each circle, called a flow graph node, represents one or more procedural statements.

A sequence of process boxes and a decision diamond can map to a single node.A sequence of process boxes and a decision diamond can map to a single node.

The arrows of a flow graph, called edges or links, represent flow of control.The arrows of a flow graph, called edges or links, represent flow of control.

An edge must terminate at a node.An edge must terminate at a node.

Areas bounded by edges are called regions.Areas bounded by edges are called regions.

Page 8: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

Compound ConditionsCompound Conditions

Compound Conditions occur when one or more Boolean operators (OR, AND, NAND, Compound Conditions occur when one or more Boolean operators (OR, AND, NAND, NOR) is/are present in a conditional statement.NOR) is/are present in a conditional statement.

IF A OR B is represented as follows:IF A OR B is represented as follows:

FIGURE 14.3FIGURE 14.3

Page 9: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

Independent Program PathsIndependent Program Paths

An independent program path is any path through the program that introduces at least An independent program path is any path through the program that introduces at least one new set of processing statements or a new condition.one new set of processing statements or a new condition.

When stated in terms of a flow graph, an independent path must move along at least When stated in terms of a flow graph, an independent path must move along at least one edge that has not been traversed before the path is defined. one edge that has not been traversed before the path is defined.

For example, a set of independent paths for the flow graph illustrated in Figure 14.2b is:For example, a set of independent paths for the flow graph illustrated in Figure 14.2b is:

Path 1: 1-11Path 1: 1-11

Path 2: 1-2-3-4-5-10-1-11Path 2: 1-2-3-4-5-10-1-11

Path 3: 1-2-3-6-8-9-10-1-11Path 3: 1-2-3-6-8-9-10-1-11

Path 4: 1-2-3-6-7-9-10-1-11Path 4: 1-2-3-6-7-9-10-1-11

Each new path introduces a new edge. Note the following path is not independent:Each new path introduces a new edge. Note the following path is not independent:

1-2-3-4-5-10-1-2-3-6-8-9-10-1-111-2-3-4-5-10-1-2-3-6-8-9-10-1-11

Page 10: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

A basis set for a flow graph is the set of paths that cover every statement in the A basis set for a flow graph is the set of paths that cover every statement in the program.program.

Therefore Paths 1, 2, 3, & 4 are the basis set for the previous figure.Therefore Paths 1, 2, 3, & 4 are the basis set for the previous figure.

If tests are designed to force execution of these paths, every statement is guaranteed If tests are designed to force execution of these paths, every statement is guaranteed to execute at least one time. Every condition will have been executed on its true to execute at least one time. Every condition will have been executed on its true and false sides.and false sides.

Note, a basis set is not unique. A number of basis sets may be derived from a Note, a basis set is not unique. A number of basis sets may be derived from a procedural design.procedural design.

How do we know how many paths to look for?How do we know how many paths to look for?

Page 11: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

Cyclomatic complexity is a software metric that provides a quantitative measure of the Cyclomatic complexity is a software metric that provides a quantitative measure of the logical complexity of a program.logical complexity of a program.

When used in the context of the basis path testing method, the value computed for When used in the context of the basis path testing method, the value computed for cyclomatic complexity defines the number of independent paths in the basis set cyclomatic complexity defines the number of independent paths in the basis set of a program and provides an upper bound for the number of tests that must be of a program and provides an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once.conducted to ensure that all statements have been executed at least once.

Cyclomatic complexity is computed a number of ways:Cyclomatic complexity is computed a number of ways:

1.1. The number of regions corresponds to the cyclomatic complexity.The number of regions corresponds to the cyclomatic complexity.

2.2. Cyclomatic complexity, V(*G), for a flow graph G, is defined as:Cyclomatic complexity, V(*G), for a flow graph G, is defined as:V(G) = E – N + 2, V(G) = E – N + 2, where E is the number of flow graph edges, and N is the number of flow graph where E is the number of flow graph edges, and N is the number of flow graph nodes.nodes.

3.3. Cyclomatic complexity, V(G), for a flow graph G, is defined as:Cyclomatic complexity, V(G), for a flow graph G, is defined as:V(G) = P + 1,V(G) = P + 1,where P is the number of predicate nodes contained in the flow graph G.where P is the number of predicate nodes contained in the flow graph G.

Page 12: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

1.1. The flow graph has 4 regions.The flow graph has 4 regions.

2.2. V(G) = 11 edges – 9 nodes +2 = 4V(G) = 11 edges – 9 nodes +2 = 4

3.3. V(G) = 3 predicate nodes + 1 = 4V(G) = 3 predicate nodes + 1 = 4

Often components with a high V(G) are a high risk for error and should be tested more Often components with a high V(G) are a high risk for error and should be tested more completely.completely.

Page 13: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing Techniques

BASIS PATH TESTINGBASIS PATH TESTING

Deriving Test CasesDeriving Test Cases

1.1. Using the design or code as a foundation, draw a corresponding flow graph.Using the design or code as a foundation, draw a corresponding flow graph.

2.2. Determine the cyclomatic complexity of the resultant flow graph.Determine the cyclomatic complexity of the resultant flow graph.

3.3. Determine a basis set of linearly independent paths.Determine a basis set of linearly independent paths.

4.4. Prepare test cases that will force execution of each path in the basis set.Prepare test cases that will force execution of each path in the basis set.

Page 14: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesBASIS PATH TESTINGBASIS PATH TESTING

Figure 14.4Figure 14.4

Page 15: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesBASIS PATH TESTINGBASIS PATH TESTING

Figure 14.5Figure 14.5

V(G) = 6 regionsV(G) = 6 regions

V(G) = 17 edges – 13 nodes + 2 = 6V(G) = 17 edges – 13 nodes + 2 = 6

V(G) = 5 predicate nodes + 1 = 6V(G) = 5 predicate nodes + 1 = 6

Page 16: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesBASIS PATH TESTINGBASIS PATH TESTING

Paths:Paths:

Path 1: 1-2-10-11-13Path 1: 1-2-10-11-13

Path 2: 1-2-10-12-13Path 2: 1-2-10-12-13

Path 3: 1-2-3-10-11-13Path 3: 1-2-3-10-11-13

Path 4: 1-2-3-4-5-8-9-2-…Path 4: 1-2-3-4-5-8-9-2-…

Path 5: 1-2-3-4-5-6-7-8-2….Path 5: 1-2-3-4-5-6-7-8-2….

Path 6: 1-2-3-4-5-6-7-8-9-2…Path 6: 1-2-3-4-5-6-7-8-9-2…

Page 17: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesBASIS PATH TESTINGBASIS PATH TESTING

Prepare test cases that will force execution of each path in the basis set.Prepare test cases that will force execution of each path in the basis set.

Page 18: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesCONTROL STRUCTURE TESTINGCONTROL STRUCTURE TESTING

Condition TestingCondition Testing

Condition Testing is a test case design method that exercises the logical conditions Condition Testing is a test case design method that exercises the logical conditions contained in a program module. contained in a program module.

A simple condition is a Boolean variable or a relational expression, possibly preceded A simple condition is a Boolean variable or a relational expression, possibly preceded with one NOT operator. A relational expression takes the formwith one NOT operator. A relational expression takes the form

EE1 1 <relational-operator> E<relational-operator> E22

Where E1 and E2 are arithmetic expressions and <relational-operator> is one of the Where E1 and E2 are arithmetic expressions and <relational-operator> is one of the following <, <=, =, <>, > or >=.following <, <=, =, <>, > or >=.

A compound condition is composed of two or more simple conditions, Boolean A compound condition is composed of two or more simple conditions, Boolean operators, and parentheses.operators, and parentheses.

Boolean operators allowed in a compound condition include OR, AND, and NOT.Boolean operators allowed in a compound condition include OR, AND, and NOT.

Errors are much more common in the neighborhood of logical conditions than they are Errors are much more common in the neighborhood of logical conditions than they are in the locus of sequential programmingin the locus of sequential programming

Page 19: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesCONTROL STRUCTURE TESTINGCONTROL STRUCTURE TESTING

Loop TestingLoop Testing

Four different classes of loops:Four different classes of loops:

Figure 14.7Figure 14.7

Page 20: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesCONTROL STRUCTURE TESTINGCONTROL STRUCTURE TESTING

Simple Loops: The following tests should be performed for simple loops, where n is the Simple Loops: The following tests should be performed for simple loops, where n is the maximum number of allowable passes through the loop.maximum number of allowable passes through the loop.

1.1. Skip the loop entirelySkip the loop entirely

2.2. Only one pass through the loopOnly one pass through the loop

3.3. Two passes through the loopTwo passes through the loop

4.4. M passes through the loop where m < nM passes through the loop where m < n

5.5. N-1, n, n+1 passes through the loopN-1, n, n+1 passes through the loop

Page 21: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesCONTROL STRUCTURE TESTINGCONTROL STRUCTURE TESTING

Nested Loops: Nested Loops:

If we extended the simple loop test cases to nested loops, the number of tests would If we extended the simple loop test cases to nested loops, the number of tests would grow geometrically.grow geometrically.

Instead use the following scheme:Instead use the following scheme:

1.1. Start at the innermost loop. Set all other loops to their minimum values.Start at the innermost loop. Set all other loops to their minimum values.

2.2. Conduct simple loop tests for the innermost loop while holding the outer loops at Conduct simple loop tests for the innermost loop while holding the outer loops at their minimum iteration parameter. Add other tests for out-of-range or excluded their minimum iteration parameter. Add other tests for out-of-range or excluded values.values.

3.3. Work outward, conducting tests for the next loop, but keeping all the other outer Work outward, conducting tests for the next loop, but keeping all the other outer loops at minimum values and other nested loops to “typical” values.loops at minimum values and other nested loops to “typical” values.

4.4. Continue until all loops have been tested.Continue until all loops have been tested.

Page 22: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesCONTROL STRUCTURE TESTINGCONTROL STRUCTURE TESTING

Concatenated LoopsConcatenated Loops

Concatenated loops can be tested using the approach defined for simple loops, if each Concatenated loops can be tested using the approach defined for simple loops, if each of the loops is independent of each other.of the loops is independent of each other.

If the two loops are concatenated and the loop counter for loop 1 is used as an initial If the two loops are concatenated and the loop counter for loop 1 is used as an initial value of loop 2, then the loops are not independent.value of loop 2, then the loops are not independent.

Unstructured LoopsUnstructured Loops

Whenever possible, this class of loops should be redesigned to reflect the use of the Whenever possible, this class of loops should be redesigned to reflect the use of the structured programming constructs.structured programming constructs.

Page 23: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesBLACK BOX TESTINGBLACK BOX TESTING

Black box testing is also called behavioral testing.Black box testing is also called behavioral testing.

Black box testing focuses on the functional requirements of software.Black box testing focuses on the functional requirements of software.

Black box testing consists of a set of input conditions that will fully exercise all the Black box testing consists of a set of input conditions that will fully exercise all the functional requirements for a program.functional requirements for a program.

Page 24: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesBLACK BOX TESTINGBLACK BOX TESTING

Equivalence PartitioningEquivalence Partitioning

EP divides the input domain of a program into classes of data from which test cases can EP divides the input domain of a program into classes of data from which test cases can be derived.be derived.

An ideal test case single handedly uncovers a class of errors that might otherwise An ideal test case single handedly uncovers a class of errors that might otherwise require many cases to be executed before the general error is observed.require many cases to be executed before the general error is observed.

An equivalence class represents a set of valid or invalid states for input conditions. An equivalence class represents a set of valid or invalid states for input conditions.

Equivalence classes may be defined according to the following guidelines:Equivalence classes may be defined according to the following guidelines:

1.1. If an input condition specifies a range, one valid and two invalid equivalence If an input condition specifies a range, one valid and two invalid equivalence classes are defined.classes are defined.

2.2. If an input condition specifies a specific value, one valid and two invalid If an input condition specifies a specific value, one valid and two invalid equivalence classes are defined.equivalence classes are defined.

3.3. If an input condition specifies a member of a set, one valid and one invalid If an input condition specifies a member of a set, one valid and one invalid equivalence class are defined.equivalence class are defined.

4.4. If an input condition is Boolean, one valid and one invalid class are defined.If an input condition is Boolean, one valid and one invalid class are defined.

Page 25: PPT

Software Engineering – Software Testing TechniquesSoftware Engineering – Software Testing TechniquesBLACK BOX TESTINGBLACK BOX TESTING

Boundary Value AnalysisBoundary Value Analysis

A great number of errors occur at the boundaries of the input domain rather that in the A great number of errors occur at the boundaries of the input domain rather that in the “center”“center”

Boundary value analysis is a test case technique that compliments equivalence Boundary value analysis is a test case technique that compliments equivalence partitioning. Rather than selecting any element of the equivalence class, BVA partitioning. Rather than selecting any element of the equivalence class, BVA leads to the selection of test cases at the “edges” of the class. leads to the selection of test cases at the “edges” of the class.

Guidelines are as follows:Guidelines are as follows:

1.1. If an input condition specifies a range bounded by values a and b, test cases If an input condition specifies a range bounded by values a and b, test cases should be designed with values a and b as well as just above and just below a should be designed with values a and b as well as just above and just below a and b.and b.

2.2. If an input condition specifies a number of values, test cases should be If an input condition specifies a number of values, test cases should be developed that exercise the minimum and maximum numbers. developed that exercise the minimum and maximum numbers.

3.3. If internal program data structures have prescribed boundaries (e.g. an array has If internal program data structures have prescribed boundaries (e.g. an array has a defined limit of 100 entries), be certain to design a test case to exercise the a defined limit of 100 entries), be certain to design a test case to exercise the data structure at its boundaries.data structure at its boundaries.