Skip to main content
Edited in response to a comment.
Source Link
Sergey Kalinichenko
  • 17.6k
  • 4
  • 59
  • 74

If you takeNeither one is "stronger" in the mathematical sense:

  • Path coverage does not imply condition coverage, as illustrated by an example in your question
  • Condition coverage does not imply path coverage, as illustrated by your comment (condition IF(A&&B) with pairs A=TRUE, B=FALSE and A=FALSE, B=TRUE).

This means that claims that either side is somehow "stronger" would be invalid.

If you "upgrade" the condition coverage to modified condition/decision coverage, thenhowever, the answer iswould be "yes": covering a conditionMC/DC always implies covering the path, but covering the path may not necessarily imply even covering the condition, let alone MC/DC.

However, this does not imply that condition coverage100% MC/DC is always better than path coverage: the tradeoff is that 100% condition coverageit comes at much steeper "price" than a 100% path coverage due to the need to write more tests. Sometimes, a lot more. This has a potential of complicating the maintenance of your test suite.

I think it is a good idea to maintain a good balance between condition/decision coverage and path coverage by path-covering simple conditions (such as argument checks of the "null or empty" sort) and condition/decision-covering statements with complex business logic.

If you take "stronger" in the mathematical sense, then the answer is "yes": covering a condition always implies covering the path, but covering the path may not necessarily imply covering the condition.

However, this does not imply that condition coverage is always better than path coverage: the tradeoff is that 100% condition coverage comes at much steeper "price" than a 100% path coverage due to the need to write more tests. Sometimes, a lot more. This has a potential of complicating the maintenance of your test suite.

I think it is a good idea to maintain a good balance between condition coverage and path coverage by path-covering simple conditions (such as argument checks of the "null or empty" sort) and condition-covering statements with complex business logic.

Neither one is "stronger" in the mathematical sense:

  • Path coverage does not imply condition coverage, as illustrated by an example in your question
  • Condition coverage does not imply path coverage, as illustrated by your comment (condition IF(A&&B) with pairs A=TRUE, B=FALSE and A=FALSE, B=TRUE).

This means that claims that either side is somehow "stronger" would be invalid.

If you "upgrade" the condition coverage to modified condition/decision coverage, however, the answer would be "yes": MC/DC always implies covering the path, but covering the path may not necessarily imply even covering the condition, let alone MC/DC.

However, this does not imply that 100% MC/DC is always better than path coverage: the tradeoff is that it comes at much steeper "price" than a 100% path coverage due to the need to write more tests. Sometimes, a lot more. This has a potential of complicating the maintenance of your test suite.

I think it is a good idea to maintain a good balance between condition/decision coverage and path coverage by path-covering simple conditions (such as argument checks of the "null or empty" sort) and condition/decision-covering statements with complex business logic.

Source Link
Sergey Kalinichenko
  • 17.6k
  • 4
  • 59
  • 74

If you take "stronger" in the mathematical sense, then the answer is "yes": covering a condition always implies covering the path, but covering the path may not necessarily imply covering the condition.

However, this does not imply that condition coverage is always better than path coverage: the tradeoff is that 100% condition coverage comes at much steeper "price" than a 100% path coverage due to the need to write more tests. Sometimes, a lot more. This has a potential of complicating the maintenance of your test suite.

I think it is a good idea to maintain a good balance between condition coverage and path coverage by path-covering simple conditions (such as argument checks of the "null or empty" sort) and condition-covering statements with complex business logic.