Paul C
Paul C

Reputation: 21

What defines 'partial' coverage in Intellij code coverage tests?

I am running Java unit tests with code coverage in IntelliJ IDEA with 'tracing' (using the default Intellij coverage tool)). I have one if-statement that always reports 'partial coverage' even though both branches are used:

Screenshot

Other if-statements are green where both paths are tested, and I've tried extracting a variable with the result of the method call. Can anyone explain why line this is reported as partial instead of complete?

Upvotes: 0

Views: 4395

Answers (1)

EricSchaefer
EricSchaefer

Reputation: 26340

Partial coverage would occur, if you have compound conditions and not all of the terms are executed. e.g.

if (isEmptyString(location) && isEmptyString(name)) {
    return false;
}

If isEmptyString(location) returns false in all test cases, isEmptyString(name) is never executed. Hence "partial coverage".

This is not the case in your code, therefore I would suppose that this is a bug in the coverage tool.

Upvotes: 3

Related Questions