Page 232 -
P. 232

8.1   Development testing  215


                                                              3                  11
                                                                4       7       10



                                                    Less than 4   Between 4 and 10  More than 10
                                                  Number of Input Values

                                                           9999                   100000
                                                             10000    50000    99999



                                               Less than 10000  Between 10000 and 99999  More than 99999
                     Figure 8.6  Equivalence
                     partitions              Input Values

                                         You identify partitions by using the program specification or user documentation
                                       and from experience where you predict the classes of input value that are likely to
                                       detect errors. For example, say a program specification states that the program
                                       accepts 4 to 8 inputs which are five-digit integers greater than 10,000. You use this
                                       information to identify the input partitions and possible test input values. These are
                                       shown in Figure 8.6.
                                         When you use the specification of a system to identify equivalence partitions, this
                                       is called ‘black-box testing’. Here, you don’t need any knowledge of how the system
                                       works. However, it may be helpful to supplement the black-box tests with ‘white-
                                       box testing’, where you look at the code of the program to find other possible tests.
                                       For example, your code may include exceptions to handle incorrect inputs. You can
                                       use this knowledge to identify ‘exception partitions’—different ranges where the
                                       same exception handling should be applied.
                                         Equivalence partitioning is an effective approach to testing because it helps
                                       account for errors that programmers often make when processing inputs at the edges
                                       of  partitions.  You  can  also  use  testing  guidelines  to  help  choose  test  cases.
                                       Guidelines encapsulate knowledge of what kinds of test cases are effective for dis-
                                       covering errors. For example, when you are testing programs with sequences, arrays,
                                       or lists, guidelines that could help reveal defects include:

                                       1.  Test software with sequences that have only a single value. Programmers natu-
                                          rally think of sequences as made up of several values and sometimes they embed
                                          this assumption in their programs. Consequently, if presented with a single-
                                          value sequence, a program may not work properly.
                                       2.  Use different sequences of different sizes in different tests. This decreases the
                                          chances that a program with defects will accidentally produce a correct output
                                          because of some accidental characteristics of the input.
                                       3.  Derive tests so that the first, middle, and last elements of the sequence are
                                          accessed. This approach is reveals problems at partition boundaries.
   227   228   229   230   231   232   233   234   235   236   237