Page 275 - DCAP305_PRINCIPLES_OF_SOFTWARE_ENGINEERING
P. 275

Unit 13: Testing



               •  Cost of tester is very high                                                     Notes
               •  White Box testing is very complex

               •  It is not possible to look into each piece of code to find out hidden errors
               •  Test cases maintenance can be tough if the implementation changes very frequently
               •  Since White Box Testing it closely tied with the application being testing, tools to cater to
                 every kind of implementation/platform may not be readily available
               •  Exhaustive testing of larger system is not possible.

            13.6 Data Flow Based Testing Techniques


            Harrold and Rothermel presented a technique for testing object-oriented software in class level. It
            is base on traditional data flood testing technique which is originally designed for unit testing of
            procedural program. Harrold and Rothermel extended the technique for object-oriented software
            by presenting a new idea for construction of control flow graph (CFG), while the part of the
            technique for creating test remained close to the traditional technique. Data flow testing is a well
            known testing technique for procedural programs. It is accepted as an effective technique for test
            case generation and also evaluation of test adequacy. The important concept of the technique is
            to test the program under test based on its data definitions and uses. For each piece of data in a
            program (usually a variable), it is defined somewhere in the program and gets used possibly in
            another place. For each variable, all definitions and uses are identified. As a variable is usually
            defined and then used later, a definition and a subsequent use without intervening definition
            forms a DU pair. Test execution is required to cover DU pairs for each variable in the program
            under test. How DU pairs are covered varies, as there are several criteria for this technique.
            For example, the all-use crition requires that for every use, there must be at least one DU pair
            of this use gets covered by the test execution. Another criterion, all-DU-path, requires that for
            every DU pair, every path between the def and the use must be covered by the test execution.
            Data flow testing technique is also based on control flow of the program under test, in addition
            to data def/use. Testing with this technique requires a control flow graph of the program under
            test, which is constructed from the code of the program. For each variable, labels are put onto
            edges in the control flow graph to show where in the program, the variable is defined or used.
            A control flow graph is drawn to present control flow of this program as shown in figure 13.1.
            Labels are put on edges where there is a definition or a use of variable maxVal.
                        /  *  *
                           * Find the index of max value in an int array.
                           *  /
                        Public int max (int [ ] data) {
                              int maxVal = 0;
                              int index = 0;
                              for (int i = 0; i < data.length; i++) {
                                    if (data [ i ] > maxVal) {
                                    i  n  d  e  x     =     i  ;
                               }
                          }
                              return index;
                     }


                                             LOVELY PROFESSIONAL UNIVERSITY                                   269
   270   271   272   273   274   275   276   277   278   279   280