clay
clay

Reputation: 65

Branch Coverage and DU Paths

Is there a situation where you can have 100% Branch Coverage and still have DU paths that have not been tested? If so, can I please have a simple example?

Thanks

Upvotes: 0

Views: 2068

Answers (1)

Edu
Edu

Reputation: 2052

If I understand definition-use paths correctly (for each set value there needs to be a tests that go to the points where the value is used), I think branch coverage doesn't guarantee this. Consider the following program:

z = "foo"

if x > 10:
    z = "bar"
else
    pass

if y > 5:
    print z
else
    pass

Now, if we test with (x = 0, y = 10) and (x = 20, y = 0), we cover all the branches. First test will evaluate false branch in the first if and true branch in the second if. Second test will evaluate true branch in the first if and false branch in the second if. All branches are covered, but there is no test where printing z would result in "bar".

Upvotes: 2

Related Questions