Closed BoAi01 closed 1 year ago
I actually feel that if every statement is covered, then every branch is covered. Any counter-examples?
In this case, if the test cases only execute the scenario where the condition is true, all the statements (statement1 and statement2) will be executed, resulting in 100% statement coverage. However, branch coverage will still be 50%, as the scenario where the condition is false has not been tested.
if (condition) {
statement1;
}
statement2;
I see. Then this makes sense now. Thanks
Path Testing >= Branch Testing >= Statement Testing
Good example, @SPWwj
I refer to this article for the comparison between these three kinds of coverages, which mentions that
Based on the textbook, we shall agree that Path Testing >= any other testing, but why Branch Testing >= Statement Testing?
More specifically I am considering a simple example to check my basic understanding:
If we have one test case
a = 1
, and theif
block is executed. What are the branch coverage rate and statement coverage rate? I think these should be 50% and 50% respectively.