Detail the path coverage and its advantages and disadvantages of the logical coverage of white box testing

definition:

To run the tested program, it is necessary to cover all possible paths in the program.

Relationship with other coverage:

The program can be thoroughly tested, covering a wider range than statement coverage, condition coverage, decision coverage, condition judgment coverage, and condition combination coverage.

Path coverage:

Path coverage = number of paths executed at least once / total number of paths
eg: There are 4 paths in the code case, and 3 paths are executed in the design test case, then the path coverage is 3/4 = 75%

Test case:

Take the following picture as an example:
Insert picture description here
According to the above picture: if we want the coverage rate to be 100%, the
judgment conditions are as follows:

  1. if (x> 0 && y> 0) judgment: recorded as P1
  2. if (magic <0) judge: record as P2
  3. x> 0: recorded as C1
  4. y> 0: recorded as C2
  5. magic <0: Recorded as C3
    test case design:

Insert picture description here
It can be seen from the above: the four path paths of abdf, acdf, abef, acef are executed, and the path coverage rate is 100%.

Advantages and disadvantages:

Advantages: The path coverage is very wide.
Disadvantages: Because path coverage needs to test all possible paths (including loops, conditional combinations, branch selection, etc.), then a large number of complex test cases need to be designed, resulting in an exponential increase in workload. In some cases, some execution paths cannot be executed.

Reference: https://www.bilibili.com/video/BV1wE411379A?from=search&seid=13283429216155494082

Published 19 original articles · praised 46 · views 1844

Guess you like

Origin blog.csdn.net/hanhanwanghaha/article/details/105680025