samedi 9 juin 2018

Clarifying what is meant by “complete path coverage”

In class, we were given this static method which we are asked to test. The method is supposed to (but won’t always) return the same integer value that was given as input.

static int identity(int x) {
        if (20 <= x && x <= 30) {
            x /= 2;
        }
        if (5 <= x && x <= 15) {
            x *= 2;
        }
        return x;
    }

The question asks us to create the minimum set of tests that has “complete path coverage”. Since there are two conditional statements, you would expect to generate 2^n tests, which is 4 in this instance. However, it is impossible to create a test where the first condition is true and the second condition is false. Does this mean that the minimum number of tests that has “complete path coverage” is 3?

Aucun commentaire:

Enregistrer un commentaire