The regular branch coverage will require two unit tests to cover a simple if statement. But if there is combound condition like if (A && B), from the control flow graph perspective, there is an additional branch if short-circuiting is used. This is in concert with cyclomatic complexity count, which gives 3 (also applying the rules that each logical operators increases the complexity by 1, because a decision node is created in case of short-circuiting). But as far as I know, the code analyzer do not consider those branches. Is it worth covering them anyway to make sure no side-effects result from partial evaluation of the expression?
vendredi 6 mai 2016
Should branches of code caused by short-circuiting be considered for code coverage?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire