Page 60 - SOFTWARE TESTING & QUALITY ASSURANCE
P. 60

Unit 4: White Box Testing



                                  6: PRINT “The time:”;Time$
                                  7: END
                     The above program can be run on a single test case with the date set to December 25, 2008. This
                     program will execute all the statements. Although we have tested each statement, the branches
                     were not tested.  Thus, code coverage analyzers will account for code branches and report both
                     the branch coverage and statement coverage. It also provides details about test effectiveness.
                3.   Condition Coverage: Condition coverage is a complicated path testing. This is done by adding an
                     extra condition to the IF statement. Condition coverage is a combination of branch coverage and
                     more detailed conditions. Branches alter the flow of sequence in a program and jump from one
                     part of the program to another. Both conditional and unconditional transfers can occur. In this
                     type of coverage, every branch of the control flow graph  (A control flow graph is a graphical
                     representation of all the paths which the program has traversed through during execution) is
                     executed at least once  and the values of the conditions  are  also exercised at least once.  The
                     simplest condition criterion called the basic or elementary condition coverage requires each
                     elementary condition to be covered, which implies that each elementary condition should have
                     both True and False outcomes at least once during the execution of test set.

                                          Number  of  executed  conditions
                    Basic Condition Coverage =
                                           Total  Number of  conditions

                                  Multiple conditions  in the ‘if statement ‘can create more  paths through the
                                  code.

                                  1: PRINT "Good Morning"
                                  2: IF Date$ = "25-12-2008" AND Time$ = "00:00:00" THEN
                                  3: PRINT "MERRY CHRISTMAS"
                                  4: END IF
                                  5: PRINT "The date is: "; Date$
                                  6: PRINT "The time is: "; Time$
                                  7: END


               In line 2 in the above program, both date and time are checked. Thus, condition coverage takes the extra
               conditions. We will require four test sets of test cases which assure that the each IF statement is covered.
               Test cases for a Full Condition Coverage
               Date$ Time$ Line # Execution
               25-12-200711:11:11 1, 2, 5, 6, 7
               25-12-2007 00:00:00 1, 2,5,6,7
               25-12-2008 11:11:11 1, 2,5,6,7
               25-12-200800:00:00 1,2,3,4,5,6,7
               All the four cases are considered to be important, since they traverse through different conditions of the
               IF statement such as False-False, False-True, True-False, and True-True.













                                        LOVELY PROFESSIONAL UNIVERSITY                           53
   55   56   57   58   59   60   61   62   63   64   65