How to calculate independent paths in a cfg?
Answers
This post follows on from the previous two in this series (theory and path coverage). A key theme of these posts is that of modeling paths through an application and then using tests to exercise those paths. What we’ve seen so far is that while many path segments are covered repeatedly, others may only be touched once. You most likely won’t have time to test them all. Along with that, some paths will be more data-dependent than others. So a selection process is critical. Here I’ll talk more about that selection process.
Using the terminology I’ve already introduced, a path through a program is a node and edge sequence from the starting node to a terminal (ending) node of the control flow graph of a program. That’s how the academics will word it anyway and while it is accurate, it can be hard to see how to apply it. In this post, I’m going to try to give an example.
Before going on I’ll state that writing tests to cover all the paths of a typical application is usually impractical, at least depending on the nature of the application and the various states it can be in based on data that is input, processed and output. This inherent complexity is why testing based on path analysis usually does not require coverage of all paths but instead focuses on coverage of the linearly independent paths.
testing independent paths