White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional...
-
Upload
dorthy-mason -
Category
Documents
-
view
223 -
download
0
Transcript of White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional...
![Page 1: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/1.jpg)
Cyclomatic complexityWhite Box Testing
![Page 2: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/2.jpg)
Correctness tests dan path coverage
Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO UNTIL atau REPEAT-UNTIL
![Page 3: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/3.jpg)
McCabe’s cyclomatic complexity metric
Dikembangkan oleh McCabe (1976) untuk mengukur kompleksitas program atau modul pada waktu yang sama sebagai jumlah maksimum independent path yang dibutuhkan untuk mencapai full line coverage pada program.
Dasar ukuran adalah teori graf dan dihitung berdasarkan kesesuaian ke sifat program yang dicapture oleh program flow graph
Independent path adalah setiap path pada program flow graph sedikitnya satu baris yang tidak dibentuk oleh independent path lain.
![Page 4: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/4.jpg)
Example
20 times
A
B
How many test cases ?
![Page 5: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/5.jpg)
Structural test - Control graph(Static point of view)
01112333344444567789
1011121213141415161617181819
void main (void) { int a, b, c; int min, med, max; if (a>b) { max=a; min=b; } else { max=b; min=a; } if (c>max) {max=c;} else if (c<min) {min=c;} med=a+b+c-min-max; if (max>min+med) {printf("impossible triangle \n");} else if (max==min) {printf("equilateral triangle \n");} else if (max==med || med==min) {printf("isoceles triangle \n");} else if ( max *max == min*min+med*med) {printf("rightangled triangle\n");} else {printf("any triangle\n");} }
v(G) = 25 - 19 + 2 = 88 Path = ??
1
10
1112
1314
3 4
5
6 7
8
9
17
1516
18
19
2
Example :if ( a > b and b > c) then
max=a;else
max = 100;end if ;
![Page 6: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/6.jpg)
RUMUS
V(G) = R V(G) = E – N +2 V(G) = P + 1
Keterangan V(G) = cyclometic complexity metric R = jumlah region dalam program flow graph
Setiap area yang melingkungi graph disebut sebuah region
E = Jumlah Edge (garis) N = Jumlah node P= Jumlah decision
![Page 7: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/7.jpg)
Structural test - Simple control structures(Static point of view)
if...else...
v(G)=2
if.....
v(G)=2while ...
v(G)=2
2
1
2
3
1
3
1
2
3
4
![Page 8: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/8.jpg)
Structural test - Independence of control paths(Static point of view)
b
e
g
a
c f
d
v(g)=10-7+2=5
This graph has 5 independent paths:C1 abcbcgC2 abefgC3 adfgC4 adefgC5 abcg
All the other paths are derived from the preceding 5 by linear combinationexample:
abcbcbefg=C1+C1+C2-C5-C5
![Page 9: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/9.jpg)
Path coverage testing
1
2
4
7
8
3
65
Next, we derive the independent paths:
Since V(G) = 4, there are four paths
Path 1: 1,2,3,6,7,8
Path 2: 1,2,3,5,7,8
Path 3: 1,2,4,7,8
Path 4: 1,2,4,7,2,4…7,8
Finally, we derive test cases to exercise these paths, i.e. choose inputs that lead to traversing the paths
![Page 10: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/10.jpg)
White BoxLogic-Coverage Testing
Statement coverageDecision coverageCondition coverageDecision-condition coverageMultiple-condition coverage
![Page 11: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/11.jpg)
Consideration
complete path testing is not a realistic goal for a program with loops.
![Page 12: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/12.jpg)
Statement coverage (1/3)
![Page 13: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/13.jpg)
Statement Coverage (2/3)
writing a single test case that traverses path ace. by setting A=2, B=0, and X=3 at point
a, Every statement would be executed
once (actually, X could be assigned any value).
![Page 14: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/14.jpg)
Statement Coverage (3/3)
Unfortunately, this criterion is a rather poor one. Perhaps the first decision should be an
or rather than an and Perhaps the second decision should have
stated X>0
Also, there is a path through the program in which X goes unchanged (the path abd)
the statement coverage criterion is so weak that it generally is useless.
![Page 15: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/15.jpg)
decision coverage orbranch coverage.
This criterion states that you must write enough test cases that each decision has a true and a false outcome at least once. each branch direction must be traversed
at least once. Decision coverage usually can satisfy
statement coverage.
![Page 16: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/16.jpg)
decision coverage orbranch coverage.
decision coverage requires that each decision have a true and a false outcome, and
that each statement be executed at least once.
has to be modified for programs that contain multiway decisions. Java programs containing select (case)
statements,
![Page 17: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/17.jpg)
decision coverage orbranch coverage.
decision coverage can be met by two test cases covering paths ace and abd or, alternatively, acd and abe
▪ A = 3, B = 0, X = 3▪ A = 2, B = 1, and X = 1.
![Page 18: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/18.jpg)
decision coverage orbranch coverage.
stronger criterion than statement coverage,
but it still is rather weak. there is only a 50 percent chance that
we would explore the path where X is not changed (abd)
only if we chose the former alternative▪ ace and abd
![Page 19: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/19.jpg)
Condition Coverage
A criterion that is sometimes stronger than decision coverage is condition coverage. write enough test cases to ensure that each
condition in a decision takes on all possible outcomes at least once.
this does not always lead to the execution of each statement,
an addition to the criterion is that each point of entry to the program or subroutine, as well as ON units, be invoked at least once.
![Page 20: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/20.jpg)
Condition Coverage
Figure 4.1 has four conditions: A>1, B=0, A=2, and X>1.
enough test cases are needed to force the situations where A>1, A<=1, B=0, and B<>0 are present at point a and
where A=2, A<>2, X>1, and X<=1 are present at point b.
▪ 1. A=2, B=0, X=4 ace▪ 2. A=1, B=1, X=1 abd
![Page 21: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/21.jpg)
Condition Coverage
Alternative
1. A=1, B=0, X=3
2. A=2, B=1, X=1 cover all condition outcomes, but they cover only two of the four
decision outcomes. both of them cover path abe
![Page 22: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/22.jpg)
decision/condition coverage.
requires sufficient test cases that each condition in a decision takes on all possible outcomes at least once,
Each decision takes on all possible outcomes at least once,
and each point of entry is invoked at least once.
![Page 23: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/23.jpg)
decision/condition coverage
A weakness with decision/condition coverage is that, although it may appear to exercise all
outcomes of all conditions, it frequently does not because certain
conditions mask other conditions.
![Page 24: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/24.jpg)
![Page 25: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/25.jpg)
Figure 4.2 is the way a compiler would generate machine code
A more thorough test coverage, appears to be the exercising of all possible outcomes of each primitive decision
The two previous decision coverage test cases do not accomplish this; they fail to exercise the false outcome of decision H and the true outcome of decision K.
![Page 26: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/26.jpg)
Multiple Condition Coverage
This criterion requires that you write sufficient test cases that all possible combinations of condition outcomes in each decision, and all points of entry, are invoked at least once.
![Page 27: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/27.jpg)
Multiple Condition Coverage
It should be easy to see that a set of test cases satisfying the multiple condition criterion also satisfies the decision-coverage, condition coverage, and decision/condition-coverage criteria.
![Page 28: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/28.jpg)
Multiple Condition Coverage
![Page 29: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/29.jpg)
Multiple condition Coverage
These combinations to be tested do not necessarily imply that eight test cases are needed.
In fact, they can be covered by four test cases.
A=2, B=0, X=4 Covers 1, 5
A=2, B=1, X=1 Covers 2, 6
A=1, B=0, X=2 Covers 3, 7
A=1, B=1, X=1 Covers 4, 8
![Page 30: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/30.jpg)
Multiple condition Coverage
The fact that there are four test cases and four distinct paths in Figure 4.1 is just coincidence.
In fact, these four test cases do not cover every path; they miss the path acd.
![Page 31: White Box Testing. Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.](https://reader036.fdokumen.com/reader036/viewer/2022062304/56649dda5503460f94ad04ad/html5/thumbnails/31.jpg)
ConclusionLogic Coverage vs Path
In the case of loops, the number of test cases required by the multiple-condition criterion is normally much less than the number of paths.