about summary refs log tree commit diff
path: root/usth/ICT2.7/P4L1 General Concepts Subtitles/19 - White Box Testing Example - lang_en_vs4.srt
blob: 896f9b1266f7f62307fc0e817c6d31817d3fe4a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
1
00:00:00,080 --> 00:00:03,086
In this case we focus on white box testing. So consider now this

2
00:00:03,086 --> 00:00:06,556
other function, called fun. And let's assume that we want to test this function

3
00:00:06,556 --> 00:00:09,777
without having a specification. So without knowing exactly what it needs to do.

4
00:00:09,777 --> 00:00:12,996
But just by looking at the code. So we will try to do the

5
00:00:12,996 --> 00:00:16,030
problem in this case is to try to just execute all the statements.

6
00:00:16,030 --> 00:00:18,995
In the function. And notice I will talk extensively of what does it

7
00:00:18,995 --> 00:00:22,560
means to do white box testing later on in the next, two classes.

8
00:00:22,560 --> 00:00:25,560
So if that's our goal, if our goal is to cover all the statements,

9
00:00:25,560 --> 00:00:27,670
any input will really do. So any test case

10
00:00:27,670 --> 00:00:30,250
will excecute all statements in the code. And we'll a

11
00:00:30,250 --> 00:00:33,801
complete, you know, white-box testing coverage for the program.

12
00:00:33,801 --> 00:00:35,865
Imagine that I now give you a specification for this

13
00:00:35,865 --> 00:00:39,071
function. And what the specification says is that this

14
00:00:39,071 --> 00:00:43,232
function inputs an integer parameter, param, and returns half of

15
00:00:43,232 --> 00:00:45,860
its value, if param is even, and its value

16
00:00:45,860 --> 00:00:50,740
unchanged otherwise. That means if param is odd. So looking

17
00:00:50,740 --> 00:00:54,320
at this specification, we can clearly see that the function fun

18
00:00:54,320 --> 00:00:57,740
works correctly only for even integers, and it doesn't work for

19
00:00:57,740 --> 00:01:00,570
odd integers. Because it computes. Half of the value of the

20
00:01:00,570 --> 00:01:04,410
parameter and returns it every time, no matter what param is. So

21
00:01:04,410 --> 00:01:07,320
this is a case in which white box testing could easily

22
00:01:07,320 --> 00:01:10,620
miss the problem, because as we said any input will exercise

23
00:01:10,620 --> 00:01:12,900
the code. It's just by chance that we could reveal one

24
00:01:12,900 --> 00:01:15,750
that revealed the problem in the code. Conversely if we were to

25
00:01:15,750 --> 00:01:19,520
work, in a black box manner. Typically looking at the specification, we

26
00:01:19,520 --> 00:01:22,390
will select at least one odd, and one even input number to

27
00:01:22,390 --> 00:01:25,010
exercise all of the specified behavior. And we will find the problem

28
00:01:25,010 --> 00:01:28,110
right away. So these two examples are just very small examples, and

29
00:01:28,110 --> 00:01:30,910
they're kind of, you know, stretched. But these kind of issues occur

30
00:01:30,910 --> 00:01:33,680
on a much bigger scale and in much more subtle ways in

31
00:01:33,680 --> 00:01:36,970
real world software. And so what this examples do is to show

32
00:01:36,970 --> 00:01:41,270
you, how black box and white box tests are really complimentary techniques.

33
00:01:41,270 --> 00:01:43,130
So in the next two lessions we will explore

34
00:01:43,130 --> 00:01:45,130
these two types of techniques in detail. We will

35
00:01:45,130 --> 00:01:48,020
see different kinds of white box and black box

36
00:01:48,020 --> 00:01:50,670
testing. And we'll talk about their strengths and the mutations