3
mars
2010
Comparatif des outils de mesure de couverture de code en Java
mars
2010
Test 5 & 6 : Try/catch/finally
On lève ou non une exception.
Code à mesurer (exception levée) :
public class App {
public void method() {
try {
System.out.println("Throw exception");
throw new NullPointerException();
}
catch (NullPointerException e) {
System.out.println("Exception catched");
}
finally {
System.out.println("Finally...");
}
}
}
public void method() {
try {
System.out.println("Throw exception");
throw new NullPointerException();
}
catch (NullPointerException e) {
System.out.println("Exception catched");
}
finally {
System.out.println("Finally...");
}
}
}
Code à mesurer (exception non levée) :
public class App {
public void method() {
try {
System.out.println("Don't throw exception");
//throw new NullPointerException();
}
catch (NullPointerException e) {
System.out.println("Exception catched");
}
finally {
System.out.println("Finally...");
}
}
}
public void method() {
try {
System.out.println("Don't throw exception");
//throw new NullPointerException();
}
catch (NullPointerException e) {
System.out.println("Exception catched");
}
finally {
System.out.println("Finally...");
}
}
}
Code JUnit :
Idem test 1.
Rapport Emma :


Rapport Cobertura :


Rapport Clover :



Un article de morgoth_fr
Ne vous inquiétez pas, une synthèse devrait venir, mais j’ai encore 2-3 tests à mener pour être exhaustif…
Stay tuned
Je ferais mieux de relire deux avant de poster :aie:
@Baptiste
Comme il le dit en intro, une analyse devrait suivre … il y a plus qu’à attendre.
Article très intéressant
Par contre, une petite conclusion serait bienvenue pour expliquer ce qu’on peut sortir de ces différents tests.