Let's go back to our test criteria subsumption representation, where
we already had branch coverage and statement coverage. In this case,
if we want to add condition coverage to this page, we
have to put it here on this side, with no relationship
of subsumption with either branch coverage or statement coverage, which
means that the criteria are not comparable. So now let's consider
again our last example, and let's use a different test
with this time. We still have two tests, but the first
one has x is equal to 0 and y is equal to minus
5. And the second one, x is equal to 5 and y is
equal to 5 as well. Let's see what happens in terms of condition
coverage, when we run these tests. If we look at the first condition, x
is equal to 0. It is both true, for the first test case,
and false for the second one. As for the second condition, y greater
than 0, it is false for the first test case and true for
the second one. Therefore we've achieved a
100% condition coverage with these two tests.
But what about branch coverage? If we consider the whole predicate,
instead of just the individual conditions, let's see what happens for the
two test cases. If we look at the first one, because
x is equal to 0, the overall predicate is true. As for
the second one, because the second condition is true, the overall
predicate is true. In other words, despite the fact that we're exercising
all the possible values for the two conditions, the overall predicate is
always true. And therefore, we're covering only one of the two branches.
So our coverage will be 50%. This is the reason
why normally the two criteria that we just saw, decision
coverage, and condition coverage are considered together. And the resulting
criterion is called branch and condition coverage, or also decision
and condition coverage. At this point the test requirements and
the coverage measure should be pretty straight forward, because they're
just considering the two criteria together. As far as the
requirements are concerned, they include
all the branches and individual conditions
in the program. Where as the coverage measure is computed
considering both coverage measures, both branch coverage and condition coverage.