Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Branch coverage with missing else

Given some code:

int(x) {
 if(x==0) { dosomething }
}

If I run this with two test cases: t1 = <0> and t2 = <2>, will this provide me with 100% branch coverage even though the else statement is missing?

In other words, does the else statement need to exist to achieve 100% branch coverage?

Thanks

like image 429
user1686342 Avatar asked Dec 12 '25 21:12

user1686342


1 Answers

Yes, these two inputs will result in full branch coverage. else is not required for full branch coverage.

You may consider that there's an empty implicit else block.

like image 167
Alex Shesterov Avatar answered Dec 15 '25 11:12

Alex Shesterov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!