Anda di halaman 1dari 28

White Box Testing

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

1. Menguji basis path (lewat flow


graph)
2. Menentukan region
3. Menghitung kompleksitas
siklomatik (pengukuran kuantitatif
thd logika program)
4. Menentukan jalur independen
5. Membuat testcase
Langkah pengujian (I)

1. Harus melalui algoritma atau listing


programnya
2. Buat flowgraph tentukan region
• Langkah pengujian (II) :
1. Tentukan kompleksitas siklomatis (yaitu
pengukuran terhadap logika program dari
banyaknya test case utk menguji seluruh
pernyataan kendali/control structure
2. Tentukan independent path/jalur
independen
– Langkah pengujian III : buat test case
Pengujian Basis path

• Dilakukan dengan membuat


flowgraph dan menentukan
REGION diagram tsb.
• Flowgraph
– Adlah grafik alir yg menggunakan
aliran kontrol logika dengan
simbol/notasi sbb :
– : node / simpul
– : edge / busur
Cyclomatic complexity (cc)
• Adlh pengukuran kuantitatif thd logika
program yaitu banyaknya test case
(kasus uji) utk menguji seluruh kendali
(control statement)
• Cara menentukan cc :
1. Cc=v(g)=banyaknya region
2. Atau dg rumus v(g)=cc=E - N+2 , e=edge,
n=node
3. V(g)=p+1, dgn p = predicate node yaitu
node yg memiliki > 1 keluaran
4. Jalur independen = independent path
– Yaitu jalur yg melalui berbagai rangkaian
pernyataan dlm satu program
Contoh
• For the video sales and rental shop example, consider the following
procedure for reserving a copy of a movie video.

• Draw the flow graph for the reserveVideoCopy procedure. Clearly


label the regions of the flow graph.

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:

which strategy (if any) is better,


white box or black box testing?

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:

• it goes into a level of detail far beyond just looking


at the output from a program, and is therefore
clearly better than black box testing on individual
small modules
• it discovers extra non-specified functions that black
box wouldn’t know to look for - such extras can
only be discovered by inspecting the code (e.g.
non-documented illegal options supplied by a
disreputable programmer)

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 maksa ….. (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)

Anda mungkin juga menyukai