vendredi 18 janvier 2019

What is the difference in structure for nested vs. compound conditional statements?

I can't quite remember how nesting conditions affects the difficulty of testing for code coverage.

I have a condition in my code that can be written in one of two ways. The first would be:

if A && B && C && D:
    // condition satisfied

The second way would be:

if A:
    if B:
        if C:
            if D:
                // condition satisfied

Is there a noteworthy difference here regarding testing for code coverage?

I'm going to write a helper function so that my actual code looks like:

if condition_met():
    // condition satisfied, do stuff

But I'll still have to unit test the conditions_met() function.

Aucun commentaire:

Enregistrer un commentaire