Path coverage testing is systematic and sequential software testing, meaning the tester assesses each line of software code.

Path coverage testing falls under the types of technical testing methods in software testing. It is labor-intensive, so it’s usually reserved for critical code sections.

Think of it this way, in car manufacturing, instead of just seeing if the vehicle runs, path coverage testing includes assessing all of its components (e.g., suspension, brakes, lights, etc.). That way, buyers won’t have any problems with the car when it goes to market, and the company won’t be liable should accidents occur or ensure too many warranties.

Read More about “Path Coverage Testing

Path coverage testing may be time-consuming but is necessary if a developer wants to guarantee that his or her program will work without hitches.

How Does Path Coverage Testing Work?

Each software is made up of several lines of code. The more complex the program is, the more lines of code it has. Path coverage testing should test for all possible scenarios to see if it works as designed.

Take this straightforward code with two possible outcomes as an example.

input x
if x > 100 then
return true
else return false

This type of software testing should cover the two scenarios the code presents—the “if” and “else” statements—to see if the software works. If the value inputted is greater than 100, the software should return the value “true.” So if you enter “200,” you’ll get the result “true.” And that’s logical since 200 is indeed greater than 100.

If the input is less than 100, the return value should be “false.” If you enter “50,” you should get the result “false.” That’s logical, too, since 50 is less than 100.

You can’t say the software works if it doesn’t give one or both of the possible results (i.e., “true” or “false”). In our examples, 200 can’t be more than 100 or less than 100. The same can be said for 50.

What Are the Steps in Path Coverage Testing?

Path coverage testing follows these four basic steps.

  1. Draw a control graph to determine different program paths. A control graph is a graphical representation of a software’s source code.
  2. Calculate the program’s cyclomatic complexity or determine the number of independent paths.
  3. Find a set of paths to use as a basis.
  4. Generate test cases to exercise each path.

Here’s an example of a control graph.

path coverage testing control graph

For this control graph, you can see three paths that require testing, namely:

  1. Path 1: Test lines 1, 2, 3, 5, 6, and 7.
  1. Path 2: Test lines 1, 2, 4, 5, 6, and 7.
  1. Path 3: Test lines 1, 6, and 7.

What Are the Advantages of Path Coverage Testing?

Since path coverage testing assesses every line of software code, it can:

  • Reduce redundant tests: Because you have already tested each line of code at least once, you don’t have to repeat other tests on the software just to see if it works properly.
  • Focus on program logic: Testers can ensure the software produces logical results. It shouldn’t, for instance, give two results for each input.
  • Execute test cases at least once: The software will run all possible scenarios since you need to execute every statement.
  • Ensure the best design: This type of testing facilitates analytical (meaning, you’ll get logical results or results that make sense) versus arbitrary (has more to do with functionality than accuracy) case design.

What Are the Different Types of Coverage?

Path coverage testing can assess the following:

  • Test coverage: Specifically measures the amount of testing performed by a set of tests. It’s calculated based on the number of different structural elements in the software.
  • Statement coverage: The percentage of executable statements a test suite has exercised. It’s calculated using the formula: Statement coverage = (Number of statements exercised / Total number of statements) * 100%.
  • Decision coverage: The percentage of decision outcomes that a test suite has exercised. 100% decision coverage implies both 100% statement coverage and 100% branch coverage. It’s calculated using the formula: Decision coverage = (Number of decision outcomes exercised / Total number of decision outcomes) * 100%.
  • Branch coverage: The percentage of branches that a test suite has exercised. 100% branch coverage implies both 100% statement coverage and 100% decision coverage.

Path coverage testing may be tedious, but it’s critical if you don’t want your software users to encounter technical problems or get inaccurate results along the way.

Key Takeaways

  • Path coverage testing is a kind of software testing wherein the tester assesses each line of software code.
  • There are four steps to path coverage testing—draw a control graph, calculate the program’s cyclomatic complexity, find a basis set of paths, and generate test cases to exercise each path.
  • Path coverage testing ​​reduces redundant tests, focuses on program logic, executes test cases at least once, and ensures the best design.

Other interesting terms…