about summary refs log tree commit diff
path: root/usth/ICT2.7/P4L3 White-Box Testing Subtitles/16 - Branch and Condition Coverage - lang_en_vs4.srt
blob: 143a534b5eae58bdebf44e08b5039f12dc2249d0 (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,052 --> 00:00:03,407
Let's go back to our test criteria subsumption representation, where

2
00:00:03,407 --> 00:00:06,770
we already had branch coverage and statement coverage. In this case,

3
00:00:06,770 --> 00:00:09,350
if we want to add condition coverage to this page, we

4
00:00:09,350 --> 00:00:12,050
have to put it here on this side, with no relationship

5
00:00:12,050 --> 00:00:15,830
of subsumption with either branch coverage or statement coverage, which

6
00:00:15,830 --> 00:00:19,270
means that the criteria are not comparable. So now let's consider

7
00:00:19,270 --> 00:00:22,108
again our last example, and let's use a different test

8
00:00:22,108 --> 00:00:25,060
with this time. We still have two tests, but the first

9
00:00:25,060 --> 00:00:27,575
one has x is equal to 0 and y is equal to minus

10
00:00:27,575 --> 00:00:30,370
5. And the second one, x is equal to 5 and y is

11
00:00:30,370 --> 00:00:33,350
equal to 5 as well. Let's see what happens in terms of condition

12
00:00:33,350 --> 00:00:36,740
coverage, when we run these tests. If we look at the first condition, x

13
00:00:36,740 --> 00:00:39,820
is equal to 0. It is both true, for the first test case,

14
00:00:39,820 --> 00:00:43,240
and false for the second one. As for the second condition, y greater

15
00:00:43,240 --> 00:00:45,800
than 0, it is false for the first test case and true for

16
00:00:45,800 --> 00:00:47,770
the second one. Therefore we've achieved a

17
00:00:47,770 --> 00:00:50,400
100% condition coverage with these two tests.

18
00:00:50,400 --> 00:00:54,020
But what about branch coverage? If we consider the whole predicate,

19
00:00:54,020 --> 00:00:56,620
instead of just the individual conditions, let's see what happens for the

20
00:00:56,620 --> 00:00:59,090
two test cases. If we look at the first one, because

21
00:00:59,090 --> 00:01:02,200
x is equal to 0, the overall predicate is true. As for

22
00:01:02,200 --> 00:01:05,750
the second one, because the second condition is true, the overall

23
00:01:05,750 --> 00:01:09,110
predicate is true. In other words, despite the fact that we're exercising

24
00:01:09,110 --> 00:01:12,520
all the possible values for the two conditions, the overall predicate is

25
00:01:12,520 --> 00:01:16,540
always true. And therefore, we're covering only one of the two branches.

26
00:01:16,540 --> 00:01:19,591
So our coverage will be 50%. This is the reason

27
00:01:19,591 --> 00:01:22,231
why normally the two criteria that we just saw, decision

28
00:01:22,231 --> 00:01:26,205
coverage, and condition coverage are considered together. And the resulting

29
00:01:26,205 --> 00:01:30,320
criterion is called branch and condition coverage, or also decision

30
00:01:30,320 --> 00:01:33,030
and condition coverage. At this point the test requirements and

31
00:01:33,030 --> 00:01:35,590
the coverage measure should be pretty straight forward, because they're

32
00:01:35,590 --> 00:01:38,120
just considering the two criteria together. As far as the

33
00:01:38,120 --> 00:01:39,960
requirements are concerned, they include

34
00:01:39,960 --> 00:01:41,880
all the branches and individual conditions

35
00:01:41,880 --> 00:01:44,580
in the program. Where as the coverage measure is computed

36
00:01:44,580 --> 00:01:49,180
considering both coverage measures, both branch coverage and condition coverage.