Is branch coverage as useful as line coverage?
<p>My organization is emphasizing a line and branch coverage of 80%. I have absolutely no problem with the line coverage requirement, but the branch coverage has given me an issue.</p>

<p>Let's take the following case in point:</p>

<pre><code>if(decisionA &amp;&amp; decisionB)
{
  // path A - do some complex ninja code stuff
}
else
{
  // path B - tell user i can't do anything
}
</code></pre>

<p>Now, I've written 2 cases, the first one that covers path A and the second one covering path B. This should give me 100% line coverage. However, this gives me only 50% branch coverage since I've only covered (True &amp;&amp; True) + (False &amp;&amp; False) while ommitting (True &amp;&amp; False) + (False &amp;&amp; True).</p>

<p>From my perspective, the values of decisionA and decisionB are trivial, and hardly worth testing. However, the blanket requirement in my organization now means I would have to write 4 test cases instead of 2. Bring multiple if's and nested if's and this becomes complicated. </p>

<p>To me, it appears that it should be in the developer's decision whether he chooses to cover branch cases, so long as he deems that the important logic (in the case the ninja code stuff in part A) is getting covered.</p>

<p>What are your thoughts on this? What do you think would be an acceptable branch coverage rate? Is my angst about enforcing a high branch coverage rate justified or am I not emphasizing code quality enough? I know this is a bit of a subjective question, but surely there are good patterns already established regarding this.</p>