Is path coverage stronger than condition coverage?

I have encountered (even in literature) two contradicting opinions related to path vs condition coverage (not branch or edge!). Some say Path coverage is stronger than the condition coverage, some say the opposite.

Having code like this:

If(X<0 OR X>100)
   DoStuff();

Path coverage – 1 test case is needed to cover the path. With X=-1, the second expression will not be tested and possible bug will be missed.
Condition coverage – test cases X=-1 and X=100 are needed to test both conditions.

Am I missing something or condition coverage is really stronger than path coverage?

Condition coverage (ISTQB):

Our next level of coverage is called condition coverage. The basic concept is that, when a decision is made by a complex expression that eventually evaluates to TRUE or FALSE, we want to make sure that each atomic condition is tested both ways.

Practical Insight Into CMMI

Condition coverage measures the true and false outcome of each Boolean
subexpression.

References:

Software Testing: Principles and Practices from Srinivasan Desikan,Gopalaswamy Ramesh: page 61

Condition coverage is a much stronger criteria than path coverage,
which in turns is a much stronger criteria than statement coverage.

4

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.

17

Path coverage is strictly more complete than branch coverage.

An example pulled from Wikipedia:

two properties of the cyclomatic complexity, M, for a specific module:

  • M is an upper bound for the number of test cases that are necessary to achieve a complete branch coverage.
  • M is a lower bound for the number of paths through the control flow graph (CFG).
if( c1() )
   f1();
else
   f2();

if( c2() )
   f3();
else
   f4();

In this example, two test cases are sufficient to achieve a complete branch coverage, while four are necessary for complete path coverage. The cyclomatic complexity of the program is 3 (as the strongly connected graph for the program contains 9 edges, 7 nodes and 1 connected component) (9-7+1).

However, as noted a little further down (bolding mine for emphasis):

Unfortunately, it is not always practical to test all possible paths through a program. Considering the example above, each time an additional if-then-else statement is added, the number of possible paths doubles. As the program grew in this fashion, it would quickly reach the point where testing all of the paths was impractical.

EDIT

Okay, I think I see where @user970696 in the comments is coming from. If I understand right, the answer is still strictly path coverage. The only time you’ll have a “special” result different from branch coverage is when there’s functions being called in the conditional, which may or may not run due to short-circuiting.

But when that happens, they count as part of the path.

Take this, for example:

if (a() && b()):
   foo()
else:
   bar()
  • Branch coverage has 2 cases:
    • (a() && b()) == True
    • (a() && b()) == False
  • Conditional coverage has 3 cases:
    • a() == False
    • a() == True && b() == False
    • a() == True && b() == True
  • Path coverage has the same 3 cases:
    • Path: a(), bar()
    • Path: a(), b(), bar()
    • Path: a(), b(), foo()

However, when you add in a second if statement, as mentioned above, the number of paths will multiply – while each individual if statement stays at the same complexity.

14

The main difference between condition coverage and path coverage is that condition coverage is local to some control structure (if, while, for, …), whereas path coverage is global to the whole program and therefore includes all possible combinations of branches (not conditions).

On the local point of view, condition coverage is stronger.

On the global point of view, path coverage is stronger. So stronger that it is usually not achievable.

As already mentioned, neither

  1. Path Coverage implies Condition Coverage NOR
  2. Condition Coverage implies Path Coverage

There are very simple examples which proof that:

(1): Path Coverage doesn’t imply Condition Coverage:

if (A and B) then
    some elementary statement(s)
end if

Path Coverage is provided by:

  • A = false
  • A = true and B = true

But: For Condition Coverage we require A = true and B = false as well.

(2): Condition Coverage doesn’t imply Path Coverage:

if (A)
    some elementary statement(s)
end if
if (B)
    some (other) elementary statement(s)
end

Condition Coverage is provided by:

  • A = false and B = false
  • A = true and B = true

But: For Path Coverage we require A = false and B = true as well as A = true and B = false.

Path coverage basically includes the coverage of the statements in the program that you have written.That is if the program contains the following lines of code as:
1. if(condition 1)
2. then call a function;
3. else
4. call that function;
5. call another function;
So if we now closely observe the code we will find that there are 5 statements in total and the two of those statements are actually conditions.
So a path coverage will start from the first path and will check if the condition is true. If not then it will switch to the else part and execute the statement 4 and 5.Thus in all the number of statements covered are 1,3,4,5.
Whereas in the condition coverage the if and the else part are checked only not the 5th statement i.e. only statements 1 and 3 are checked. But also note that if there were only conditions then here in this case path coverage=statement coverage.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật