Skip to content

Why is this true? 100% path coverage can require more test cases than 100% statement coverage of the same code. #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
larrylawl opened this issue Nov 23, 2019 · 2 comments

Comments

@larrylawl
Copy link

Lecture 7 Quiz Part 2
Aren't paths a subset of statements? Thus if you have executed all statements, you would have executed all the paths.

Screenshot 2019-11-23 at 8 29 18 AM

@danielwys
Copy link

This was previously talked about in #134 and I’ll reproduce my answer below:

I think this is best illustrated with an example.

Let's say we have a while loop that can loop up to 100 times.

For us to achieve a 100% statement coverage - we just need to test one iteration of the while loop. That executes all the statements within the while loop's code block - thereby achieving full statement coverage.

To achieve full path coverage, we have to test for every possible path - that means that we test the while loop for 1, 2, 3 ... 99, 100 iterations each time, to ensure that it produces the correct result each time. That's a far more comprehensive test, and only when all paths have been exhausted through testing can it be considered full path coverage. And definitely a lot more work to be done, testing-wise.

This applies to any form of conditionals or loops within a program - you'd have to test all possible number of iterations and/or all possible branches to ensure 100% path coverage, as compared to once for statement coverage.

Hope that illustrates it for you!

@larrylawl
Copy link
Author

Got it, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants