about summary refs log tree commit diff
path: root/usth/ICT2.7/P4L3 White-Box Testing Subtitles/29 - Review Quiz Solution - lang_en_vs4.srt
blob: 1e3228c656b73f4618802ad593cd48ba3d48224b (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
1
00:00:00,230 --> 00:00:02,520
And the answer in this case is no. And

2
00:00:02,520 --> 00:00:05,480
the reason for this is because this code is

3
00:00:05,480 --> 00:00:08,950
unreachable. This is dead code because no matter the

4
00:00:08,950 --> 00:00:12,560
value of j, this condition will always be false because

5
00:00:12,560 --> 00:00:14,770
i will always be 0. And notice that this

6
00:00:14,770 --> 00:00:17,670
is a small example, but another important truth is

7
00:00:17,670 --> 00:00:22,520
that any non-trivial program contains dead or unreachable code,

8
00:00:22,520 --> 00:00:25,610
code that no matter how well we test our system,

9
00:00:25,610 --> 00:00:28,450
we will never be able to exercise. Why is that? Various

10
00:00:28,450 --> 00:00:31,030
reasons. For example, defensive programming or,

11
00:00:31,030 --> 00:00:33,600
for example, developing for future releases.

12
00:00:33,600 --> 00:00:36,320
So there might be pieces of code that are added, but they're

13
00:00:36,320 --> 00:00:39,380
still not activated. They're still not invoked by any other part of

14
00:00:39,380 --> 00:00:41,970
the code because of modifications to the code. There are some

15
00:00:41,970 --> 00:00:44,480
parts that were executed before and in the new version of the

16
00:00:44,480 --> 00:00:47,915
program, they are no longer exercised. They are no longer executable. But

17
00:00:47,915 --> 00:00:50,760
they still remain in the code base. And this is a very,

18
00:00:50,760 --> 00:00:54,560
very normal situation for this reason and many more. And this is

19
00:00:54,560 --> 00:00:56,790
an important concept because this affects

20
00:00:56,790 --> 00:00:58,760
the very meaning of coverage measures. If

21
00:00:58,760 --> 00:01:01,225
there is some unreachable code, we will never be able to reach

22
00:01:01,225 --> 00:01:04,709
100% code coverage. And in fact, if you remember, at the beginning of

23
00:01:04,709 --> 00:01:07,380
the lesson, we discussed this concept and asked you why you think

24
00:01:07,380 --> 00:01:10,470
that, in the industry, the target for coverage is not 100% but less

25
00:01:10,470 --> 00:01:12,850
that that. And that's the answer, to account for the fact that there

26
00:01:12,850 --> 00:01:15,890
are infeasibility problems that I have to take into account when I test

27
00:01:15,890 --> 00:01:19,920
the code, infeasible paths, unexecutable statements, conditions that can never

28
00:01:19,920 --> 00:01:22,780
be true, and so on. So most criteria, if not

29
00:01:22,780 --> 00:01:24,620
all, are affected, and we need to take that into

30
00:01:24,620 --> 00:01:27,270
account when we try to achieve a given coverage target.