10/31/20 10:36 AM 1
White Box or Structural Testing
• also known as glass box testing, each name
implying that the internal structure of the
program is visible, not hidden inside a black box
• tester makes use of the implementation,
analysing the source code to derive test cases
• complements black box testing, white box test
cases are added to the black box ones
• provides a more comprehensive level of testing
• Merancang test case dg menggunakan struktur
kontrol desain prosedural untuk mmperoleh test
case
2
10/31/20 10:36 AM
Karakteristik test case dr WB
testing
1. Memberikan jaminan bahwa semua
jalur independen pd suatu modul telah
digunakan minimal 1 kali
2. Menggunakan semua keputusan logis
dari sisi TRUE dan FALSE
3. Mengeksekusi semua loop pada
batasannya dan pd batas
operasionalnya
4. Menggunakan struktur data internal
untuk menjamin validitasnya
3
10/31/20 10:36 AM
Teknik pegujian WB
1. Pengujian Basis Path
• Melalui diagram alir dan diagram graph
• Menentukan kompleksitas siklomatis:
pengukuran kuantitatif thd kompleksitas
suatu program.
• Jumlah kompleksitas siklomatis
menentukan jalur independen suatu
program
2. Pengujian struktur kontrol
• Pengujian kondisi : menggunakan kondisi
logis suatu program.
• Bentuk : E1 (operator relasional) E2
4
10/31/20 10:36 AM
Basis Path/Control Structure Testing
• Proposed by Tom McCabe
• The basis path method enables the test case designer to
derive a logical complexity measure of a procedural design
and use this measure as a guide for defining a basis set of
execution paths
5
10/31/20 10:36 AM
IF
If - then If – then-else
6
10/31/20 10:36 AM
While
While
7
10/31/20 10:36 AM
Repeat
1
(1)
2
(2)
(3) 3 F
4) T
8
10/31/20 10:36 AM
Case
9
10/31/20 10:36 AM
Strategi white box
14
10/31/20 10:36 AM
Flow graph
15
10/31/20 10:36 AM
Basis Path
16
10/31/20 10:36 AM
Pseudo Code - Flow Chart
17
10/31/20 10:36 AM
Flow Chart - Flow Graph
18
10/31/20 10:36 AM
Operator Logika
19
10/31/20 10:36 AM
Cyclomatic Complexity = CC
( V(G) )
20
10/31/20 10:36 AM
Independent Path
21
10/31/20 10:36 AM
White Box versus Black Box
• question:
22
10/31/20 10:36 AM
Advantages of Black Box Testing
black box is better in that it discovers:
• missing functions
• functions which don’t correspond to the spec
• weaknesses in the spec
(e.g. “any integer” rather than -32768 to
32767)
• interface errors between modules
• performance weaknesses
• initialisation errors
• termination errors
23
10/31/20 10:36 AM
Advantages of White Box Testing
white box is better than black box in that:
24
10/31/20 10:36 AM
Conclusion
• the list of advantages for black box testing looks
more impressive but the first white box advantage
concerning level of detail makes white box
methods indispensable
• but this level of detail has disadvantages, and
black box becomes more relevant as modules are
aggregated and become larger and larger
• then we can’t think of path coverage and must be
satisfied with simply determining that the product
seems to do what we intended
• answer: both are essential, they complement
each other
25
10/31/20 10:36 AM
LATIHAN SOAL
Program Coba3;
Program Coba1; 3. Var a , b : integer;
1.
Var a , b : integer; Begin
Begin A := 5; {1}
a := 5; {1} If a > 3 then {2}
b := 10; {2} b := 2; {3}
writeln(a,b); {3} writeln(a,b); {4}
end. end. {5}
Program Coba4;
2. Program Coba2; var a : integer;
Var a , b : integer; 4. begin
Begin a := 5; {1}
a := 5; {1} while a < 10 do {2}
b := 8; begin {3}
if a > b then {2} a := a + 1; {4}
a := 2 {3} end; {5}
else a := a + 10; {6}
b := a; {4} writeln; {7}
end. {5} end.
26
10/31/20 10:36 AM
LATIHAN SOAL
5. Program Coba5;
Var a, b : integer;
Begin
Readln (a, b); {1}
Case a of {2}
1 : if a > b then {3}
writeln(a); {4}
2 : if a < b then {5}
writeln(b); {6}
end; {7}
writeln(a, b); {8}
end.
27
10/31/20 10:36 AM
7. Read(a,b,c) ….. (1)
if (a>b) AND (a >c) …….(2,3)
6. Read (a,b) ….. (1) then maksa ….. (4)
If a>3 OR b <=10 ….. (2,3) else if (b>c) …… (5)
then a 2 …. (4) then maks b …(6) else
else b a+b… (5) maks c ….(7)
Endif (6) Endif ….. (8)
Write (a,b)(7) Endif …… (9)
write (maks) …… (10)
if a<0 ……(11)
then write (“negatif”) …(12)
endif …(13)
write (a,b,c) …(14)