samedi 30 avril 2016

Please confirm/comment on Branch Coverage issue I'm seeing with EclEmma Eclipse Plugin

After running this unit testing using EclEmma Eclipse code coverage plugin, it returns 100% Branch coverage, i.e. 4 out of 4 branches covered, I expect only 2 out of 4 branches covered here i.e. 50% coverage. If I turn out to be correct can anyone suggest a better branch coverage tool please. Thanks in advance.

@Test
public void testTT(){;
    assertTrue(bar(true, true)==3);
}

@Test
public void testFF(){;
    assertTrue(bar(false, false)==8);
}


int bar(boolean cond1, boolean cond2) {
      int answer = 1;
      if (cond1) {
          answer = answer * a();
      } else {
          answer = answer * b();
      }

      if (cond2) {
          answer = answer * c();
      } else {
          answer = answer * d();
      }
    return answer;
    }

private int a(){
    return 1;
}

private int b(){
    return 2;
}

private int c(){
    return 3;
}

private int d(){
    return 4;
}

Aucun commentaire:

Enregistrer un commentaire