1.
Software Engineering – Software Testing Techniques FUNDAMENTALS 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 not redundant A good test should be neither too simple nor to complex.
2.
Software Engineering – Software Testing Techniques <ul><li>BLACK BOX AND WHITE BOX TESTING </li></ul><ul><li>One can test an engineered product by: </li></ul><ul><li>Knowing the specified function that a product was designed to perform. </li></ul><ul><li>Knowing the internal workings of a product </li></ul><ul><li>Black box testing alludes to tests that are conducted at the software interface. </li></ul><ul><li>A black box test examines some fundamental aspect of a system with little regard for the internal structure of the software. </li></ul><ul><li>White-box testing of software is predicated on close examination of procedural detail. </li></ul><ul><li>Logical paths through the software and collaborations between components are tested by providing test cases that exercise specific sets of conditions and/or loops. </li></ul>
3.
Software Engineering – Software Testing Techniques <ul><li>BLACK BOX AND WHITE BOX TESTING </li></ul><ul><li>White box testing is sometimes called glass box testing. </li></ul><ul><li>White box testing uses the control structure described as part of the component level design to derive test cases. </li></ul><ul><li>Using white box testing methods, the software engineer can derive test cases that: </li></ul><ul><li>guarantee that all independent paths within a module have been exercised at least once. </li></ul><ul><li>exercise all logical decisions on their true and false sides. </li></ul><ul><li>execute all loops at their boundaries and within their operational bounds </li></ul><ul><li>exercise internal data structures to ensure their validity. </li></ul>
4.
Software Engineering – Software Testing Techniques BASIS PATH TESTING 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 basis set of execution paths. Test cases derived to exercise the basis set are guaranteed to execute every statement in the program at least one time during testing.
5.
Software Engineering – Software Testing Techniques BASIS PATH TESTING FLOW GRAPH NOTATION A flow graph depicts logical control flow using the notation shown below: Each structured construct corresponds to a flow graph symbol.
6.
Software Engineering – Software Testing Techniques BASIS PATH TESTING Flow charts and flow graphs correspond to one another. The flow chart depicts the program control structure. The flow graph assumes no compound structures.
7.
Software Engineering – Software Testing Techniques BASIS PATH TESTING Flow charts and flow graphs correspond to one another. 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. The arrows of a flow graph, called edges or links, represent flow of control. An edge must terminate at a node. Areas bounded by edges are called regions.
8.
Software Engineering – Software Testing Techniques BASIS PATH TESTING Compound Conditions Compound Conditions occur when one or more Boolean operators (OR, AND, NAND, NOR) is/are present in a conditional statement. IF A OR B is represented as follows: FIGURE 14.3
9.
Software Engineering – Software Testing Techniques BASIS PATH TESTING Independent Program Paths An independent program path is any path through the program that introduces at least 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 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: Path 1: 1-11 Path 2: 1-2-3-4-5-10-1-11 Path 3: 1-2-3-6-8-9-10-1-11 Path 4: 1-2-3-6-7-9-10-1-11 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-11
10.
Software Engineering – Software Testing Techniques BASIS PATH TESTING A basis set for a flow graph is the set of paths that cover every statement in the program. 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 to execute at least one time. Every condition will have been executed on its true and false sides. Note, a basis set is not unique. A number of basis sets may be derived from a procedural design. How do we know how many paths to look for?
11.
Software Engineering – Software Testing Techniques <ul><li>BASIS PATH TESTING </li></ul><ul><li>Cyclomatic complexity is a software metric that provides a quantitative measure of the logical complexity of a program. </li></ul><ul><li>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 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. </li></ul><ul><li>Cyclomatic complexity is computed a number of ways: </li></ul><ul><li>The number of regions corresponds to the cyclomatic complexity. </li></ul><ul><li>Cyclomatic complexity, V(*G), for a flow graph G, is defined as: V(G) = E – N + 2, where E is the number of flow graph edges, and N is the number of flow graph nodes. </li></ul><ul><li>Cyclomatic complexity, V(G), for a flow graph G, is defined as: V(G) = P + 1, where P is the number of predicate nodes contained in the flow graph G. </li></ul>
12.
Software Engineering – Software Testing Techniques <ul><li>BASIS PATH TESTING </li></ul><ul><li>The flow graph has 4 regions. </li></ul><ul><li>V(G) = 11 edges – 9 nodes +2 = 4 </li></ul><ul><li>V(G) = 3 predicate nodes + 1 = 4 </li></ul><ul><li>Often components with a high V(G) are a high risk for error and should be tested more completely. </li></ul>
13.
Software Engineering – Software Testing Techniques <ul><li>BASIS PATH TESTING </li></ul><ul><li>Deriving Test Cases </li></ul><ul><li>Using the design or code as a foundation, draw a corresponding flow graph. </li></ul><ul><li>Determine the cyclomatic complexity of the resultant flow graph. </li></ul><ul><li>Determine a basis set of linearly independent paths. </li></ul><ul><li>Prepare test cases that will force execution of each path in the basis set. </li></ul>
17.
Software Engineering – Software Testing Techniques BASIS PATH TESTING Prepare test cases that will force execution of each path in the basis set.
18.
Software Engineering – Software Testing Techniques CONTROL STRUCTURE TESTING Condition Testing Condition Testing is a test case design method that exercises the logical conditions contained in a program module. A simple condition is a Boolean variable or a relational expression, possibly preceded with one NOT operator. A relational expression takes the form E 1 <relational-operator> E 2 Where E1 and E2 are arithmetic expressions and <relational-operator> is one of the following <, <=, =, <>, > or >=. A compound condition is composed of two or more simple conditions, Boolean operators, and parentheses. 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 in the locus of sequential programming
19.
Software Engineering – Software Testing Techniques CONTROL STRUCTURE TESTING Loop Testing Four different classes of loops: Figure 14.7
20.
Software Engineering – Software Testing Techniques <ul><li>CONTROL STRUCTURE TESTING </li></ul><ul><li>Simple Loops: The following tests should be performed for simple loops, where n is the maximum number of allowable passes through the loop. </li></ul><ul><li>Skip the loop entirely </li></ul><ul><li>Only one pass through the loop </li></ul><ul><li>Two passes through the loop </li></ul><ul><li>M passes through the loop where m < n </li></ul><ul><li>N-1, n, n+1 passes through the loop </li></ul>
21.
Software Engineering – Software Testing Techniques <ul><li>CONTROL STRUCTURE TESTING </li></ul><ul><li>Nested Loops: </li></ul><ul><li>If we extended the simple loop test cases to nested loops, the number of tests would grow geometrically. </li></ul><ul><li>Instead use the following scheme: </li></ul><ul><li>Start at the innermost loop. Set all other loops to their minimum values. </li></ul><ul><li>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 values. </li></ul><ul><li>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. </li></ul><ul><li>Continue until all loops have been tested. </li></ul>
22.
Software Engineering – Software Testing Techniques CONTROL STRUCTURE TESTING Concatenated Loops Concatenated loops can be tested using the approach defined for simple loops, if each 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 value of loop 2, then the loops are not independent. Unstructured Loops Whenever possible, this class of loops should be redesigned to reflect the use of the structured programming constructs.
23.
Software Engineering – Software Testing Techniques BLACK BOX TESTING Black box testing is also called behavioral testing. 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 functional requirements for a program.
24.
Software Engineering – Software Testing Techniques <ul><li>BLACK BOX TESTING </li></ul><ul><li>Equivalence Partitioning </li></ul><ul><li>EP divides the input domain of a program into classes of data from which test cases can be derived. </li></ul><ul><li>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. </li></ul><ul><li>An equivalence class represents a set of valid or invalid states for input conditions. </li></ul><ul><li>Equivalence classes may be defined according to the following guidelines: </li></ul><ul><li>If an input condition specifies a range, one valid and two invalid equivalence classes are defined. </li></ul><ul><li>If an input condition specifies a specific value, one valid and two invalid equivalence classes are defined. </li></ul><ul><li>If an input condition specifies a member of a set, one valid and one invalid equivalence class are defined. </li></ul><ul><li>If an input condition is Boolean, one valid and one invalid class are defined. </li></ul>
25.
Software Engineering – Software Testing Techniques <ul><li>BLACK BOX TESTING </li></ul><ul><li>Boundary Value Analysis </li></ul><ul><li>A great number of errors occur at the boundaries of the input domain rather that in the “center” </li></ul><ul><li>Boundary value analysis is a test case technique that compliments equivalence partitioning. Rather than selecting any element of the equivalence class, BVA leads to the selection of test cases at the “edges” of the class. </li></ul><ul><li>Guidelines are as follows: </li></ul><ul><li>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 and b. </li></ul><ul><li>If an input condition specifies a number of values, test cases should be developed that exercise the minimum and maximum numbers. </li></ul><ul><li>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 data structure at its boundaries. </li></ul>
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.
Be the first to comment