Percent of if statements with both branches executed based on branch coverage percent?

StackOverflow https://stackoverflow.com/questions/21742165

  •  10-10-2022
  •  | 
  •  

Domanda

I was wondering about branch coverage. Is it possible, based on branch coverage, to calculate how the percentage of if-statements that have executed both of their branches?

È stato utile?

Soluzione

if(...)
{
    A
}
else
{
    B
}
if(...)
{
    C
}
else
{
    D
}

Execute two times: AC and AC
50% Branch coverage (like described in your comment), 0% of the if-else´s fully covered.

if(...)
{
    if(...)
    {
        A
    }
    else
    {
        B
    }
}
else
{
    if(...)
    {
        C
    }
    else
    {
        D
    }
}

Execute two times: AC and AD
50% Branch coverage (2 of 4), but now 33% of the if-else´s fully covered.
...so no, not possible in my opinion.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top