Hacker News new | past | comments | ask | show | jobs | submit login

Branch coverage is a tiny fraction of total program state coverage.



Could yo I elaborate on this? Do you mean things like exceptions that are not explicitly dealt with in the code?


Branch coverage just means you’ve taken every branch, not every combination of every branch, for starters.

Then there’s branchless boundary conditions e.g. your software might fuck up on overflow, but there’s no branching, at least not in your code. Just things which get incoherent in ways you had not anticipated.


A simple example is when somewhere in code you set a value that causes you to go into the wrong branch later. You may have tested that every single branch does what it is supposed to, but this "state here causes unexpected behavior there" can still be open.


> Could yo I elaborate on this?

Think about it for a second. Imagine you have

function(bool foo, bool bar) {

   if(foo) {
      //Something
   } else {
      //Something else
   }

   if(bar) {
      //Something
   } else {
      //Something else
   }
}

If you add two unit tests that test foo(true,true) and foo(false, false) you get 100% line and branch coverage, but only hit 50% path coverage.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: