The art of software testing. Myers (2nd edition) (2004) (811502), страница 15
Текст из файла (страница 15)
Figure 4.14 contains the complete graph with the constraintconditions. Notice that, at most, one of the causes 5, 6, 7, and 8 canbe present. All other cause constraints are the requires condition.Notice that cause 17 (multiple output lines) requires the not of cause8 (second operand is omitted); cause 17 can be present only whencause 8 is absent. Again, you should explore the constraint conditionscarefully.Figure 4.12Beginning of the graph for the DISPLAY Command.76Figure 4.13Full cause-effect graph without constraints.77Figure 4.14Complete cause-effect graph of the DISPLAY Command.1RRV3291231VVR3736V3R4925R39V6RE93R73540V8V33RVV949RR10R38VVR9511R12VV13R963414VRRR15R1617187897Test-Case Design79The next step is the generation of a limited-entry decision table.For readers familiar with decision tables, the causes are the conditionsand the effects are the actions. The procedure used is as follows:1.
Select an effect to be the present (1) state.2. Tracing back through the graph, find all combinations ofcauses (subject to the constraints) that will set this effect to 1.3. Create a column in the decision table for each combinationof causes.4. For each combination, determine the states of all othereffects and place these in each column.In performing step 2, the considerations are as follows:1. When tracing back through an or node whose output shouldbe 1, never set more than one input to the or to 1 simultaneously. This is called path sensitizing.
Its objective is to preventthe failure to detect certain errors because of one causemasking another cause.2. When tracing back through an and node whose outputshould be 0, all combinations of inputs leading to 0 outputmust, of course, be enumerated. However, if you are exploring the situation where one input is 0 and one or more ofthe others are 1, it is not necessary to enumerate all conditions under which the other inputs can be 1.3. When tracing back through an and node whose outputshould be 0, only one condition where all inputs are zeroneed be enumerated. (If the and is in the middle of the graphsuch that its inputs come from other intermediate nodes,there may be an excessively large number of situations underwhich all of its inputs are 0.)These complicated considerations are summarized in Figure 4.15.Figure 4.16 is used as an example.Assume that we want to locate all input conditions that cause theoutput state to be 0.
Consideration 3 states that we should list only80The Art of Software TestingFigure 4.15Considerations used when tracing the graph.one circumstance where nodes 5 and 6 are 0. Consideration 2 statesthat, for the state where node 5 is 1 and node 6 is 0, we should listonly one circumstance where node 5 is 1, rather than enumerating allpossible ways that node 5 can be 1. Likewise, for the state where node5 is 0 and node 6 is 1, we should list only one circumstance wherenode 6 is 1 (although there is only one in this example).
Consideration 1 states that where node 5 should be set to 1, we should not setnodes 1 and 2 to 1 simultaneously. Hence, we would arrive at fivestates of nodes 1 through 4, for example, the values01110000000001100101(5=0, 6=0)(5=1, 6=0)(5=1, 6=0)(5=1, 6=0)(5=0, 6=1)Test-Case Design81Figure 4.16Sample graph to illustrate the tracing considerations.rather than the 13 possible states of nodes 1 through 4 that lead to a0 output state.These considerations may appear to be capricious, but they havean important purpose: to lessen the combined effects of the graph.They eliminate situations that tend to be low-yield test cases. If lowyield test cases are not eliminated, a large cause-effect graph will produce an astronomical number of test cases. If the number of test casesis too large to be practical, you will select some subset, but there is noguarantee that the low-yield test cases will be the ones eliminated.Hence, it is better to eliminate them during the analysis of the graph.The cause-effect graph in Figure 4.14 will now be converted intothe decision table.
Effect 91 will be selected first. Effect 91 is presentif node 36 is 0. Node 36 is 0 if nodes 32 and 35 are 0,0; 0,1; or 1,0;and considerations 2 and 3 apply here. By tracing back to the causesand considering the constraints among causes, you can find the combinations of causes that lead to effect 91 being present, althoughdoing so is a laborious process.The resultant decision table under the condition that effect 91 ispresent is shown in Figure 4.17 (columns 1 through 11). ColumnsFigure 4.17First half of the resultant decision table.12345678910 1112131415161711111111111111111121001111111111111130101111111011111111001111405611107080111111111119111100011110111010111100111120131001114010110150161718911111111111100000092000000000011111009300000000000000011940000000000000000095000000000000000009600000000000000000970000000000000000082Test-Case Design83(tests) 1 through 3 represent the conditions where node 32 is 0 andnode 35 is 1.
Columns 4 through 10 represent the conditions wherenode 32 is 1 and node 35 is 0. Using consideration 3, only one situation (column 11) out of a possible 21 situations where nodes 32 and35 are 0 is identified. Blanks in the table represent “don’t care” situations (i.e., the state of the cause is irrelevant) or indicate that thestate of a cause is obvious because of the states of other dependentcauses (e.g., in column 1, we know that causes 5, 7, and 8 must be 0because they exist in an “at most one” situation with cause 6).Columns 12 through 15 represent the situations where effect 92 ispresent. Columns 16 and 17 represent the situations where effect 93is present.
Figure 4.18 represents the remainder of the decision table.The last step is to convert the decision table into 38 test cases. Aset of 38 test cases is listed here. The number or numbers beside eachtest case designate the effects that are expected to be present. Assumethat the last location in memory on the machine being used is 7FFF.12345678910111213141516171819DISPLAY 234AF74-123DISPLAY 2ZX4-3000DISPLAY HHHHHHHH-2000DISPLAY 200 200DISPLAY 0-22222222DISPLAY 1-2XDISPLAY 2-ABCDEFGHIDISPLAY 3.1111111DISPLAY 44.$42DISPLAY 100.$$$$$$$DISPLAY 10000000-MDISPLAY FF-8000DISPLAY FFF.7001DISPLAY 8000-ENDDISPLAY 8000-8001DISPLAY AA-A9DISPLAY 7000.0DISPLAY 7FF9-ENDDISPLAY 1(91)(91)(91)(91)(91)(91)(91)(91)(91)(91)(91)(92)(92)(92)(92)(93)(93)(94, 97)(94, 97)Figure 4.18Second half of the resultant decision table.1819202122232425000026272829303132333435000363738111111111111111211111111111111311111111111111411111111111111511611711811111111111111191111111011111111111111121111111311111114111111151111111611111117000000000000111111111181111000000001110000009100000000000000000000092000000000000000000000930000000000000000000009411111111111100000000095000000000000111111111960000111111110001111119711110000000011100000084Test-Case Design20212223242526272829303132w333435363738DISPLAY 21-29DISPLAY 4021.ADISPLAY –ENDDISPLAYDISPLAY –FDISPLAY .EDISPLAY 7FF8-ENDDISPLAY 6000DISPLAY A0-A4DISPLAY 20.8DISPLAY 7001-ENDDISPLAY 5-15DISPLAY 4FF.100DISPLAY –ENDDISPLAY –20DISPLAY .11DISPLAY 7000-ENDDISPLAY 4-14DISPLAY 500.1185(94, 97)(94, 97)(94, 96)(94, 96)(94, 96)(94, 96)(94, 96)(94, 96)(94, 96)(94, 96)(95, 97)(95, 97)(95, 97)(95, 96)(95, 96)(95, 96)(95, 96)(95, 96)(95, 96)Note that where two or more different test cases invoked, for themost part, the same set of causes, different values for the causes wereselected to slightly improve the yield of the test cases.
Also note that,because of the actual storage size, test case 22 is impossible (it willyield effect 95 instead of 94, as noted in test case 33). Hence, 37 testcases have been identified.RemarksCause-effect graphing is a systematic method of generating test casesrepresenting combinations of conditions. The alternative would bean ad hoc selection of combinations, but, in doing so, it is likely thatyou would overlook many of the “interesting” test cases identified bythe cause-effect graph.Since cause-effect graphing requires the translation of a specification into a Boolean logic network, it gives you a different perspective86The Art of Software Testingon, and additional insight into, the specification. In fact, the development of a cause-effect graph is a good way to uncover ambiguitiesand incompleteness in specifications.
For instance, the astute readermay have noticed that this process has uncovered a problem in thespecification of the DISPLAY command. The specification states thatall output lines contain four words. This cannot be true in all cases; itcannot occur for test cases 18 and 26 since the starting address is lessthan 16 bytes away from the end of memory.Although cause-effect graphing does produce a set of useful testcases, it normally does not produce all of the useful test cases thatmight be identified.
For instance, in the example we said nothingabout verifying that the displayed memory values are identical to thevalues in memory and determining whether the program can displayevery possible value in a memory location. Also, the cause-effectgraph does not adequately explore boundary conditions.