written 8.7 years ago by | • modified 8.7 years ago |
This question appears in Mumbai University > Software Testing & Quality Assurance Subject
Marks: 10 M
Year: June 2012
written 8.7 years ago by | • modified 8.7 years ago |
This question appears in Mumbai University > Software Testing & Quality Assurance Subject
Marks: 10 M
Year: June 2012
written 8.7 years ago by | • modified 8.7 years ago |
public static double Return Average ( int value [ ], int AS, int MIN, int MAX)
{
int i, ti, tv, sum;
doubleav;
i=0 ;ti= 0; tv=0 ; sum = 0;
while ( ti< AS && value[i] != -999)
{
ti++ ;
if( value [i] >= MIN && value [i] < = MAX)
{
tv++ ;
sum = sum + value [i] ;
}
i++; }
if(tv<0)
av = (double) sum/tv;
else
av = (double) -999;
return (av) ;
}
Control Flow Graph for Return Average Method :
Figure : A CFG Representation of ReturnAverage( ). Numbers 1 – 13 are the nodes.
Coverage criteria for Return Average Code :
Paths for branch coverage for ReturnAverage program are :
BCPath1 : 1-2-3(F)-10(F)-11-13
BCPath2 : 1-2-3(T)-4(F)-10(F)-11-13
BCPath3 : 1-2-3(T)-4(T)-5-6(F)-7-8-9-3(F)-10(T)-12-13
BCPath4 : 1-2-3(T)-4(T)-5-6(F)-9-3(F)-10(F)-11-13
BCPath5 : 1-2-3(T)-4(T)-5-6(T)-7(F)-9-3(F)-10(F)-11-13
Statement Coverage Criteria :Statement Coverage criteria refers to executing individual program statements and observing the outcome. 100% statement coverage has been achieved if all the statements have been executed at least once.
Paths for statement coverage for ReturnAverage program are :
SCPath1 : 1-2-3(F)-10(F)-11-13
SCPath2 : 1-2-3(T)-4(T)-5-6(T)-7(T)-8-9-3(F)-10(T)-12-13
Path Selection Criteria :
Select all the paths.
Select paths to achieve complete statement coverage.
Select paths to achieve complete branch coverage.
Select paths to achieve predicate coverage.
Path Selection Criteria for ReturnAverage program are :