Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading Line Coverage Calculation for @DoNotMutate Methods #1374

Open
see-quick opened this issue Jan 13, 2025 · 0 comments
Open

Misleading Line Coverage Calculation for @DoNotMutate Methods #1374

see-quick opened this issue Jan 13, 2025 · 0 comments

Comments

@see-quick
Copy link
Contributor

This issue arises from methods annotated with @DoNotMutate (those methods, which are typically impossible to test on the UNIT level). These methods are excluded from mutation testing but still contribute to the line coverage calculation. The line coverage suggests insufficient testing, even though these methods are exercised through integration tests.

Expected Behavior:

For methods annotated with @DoNotMutate:

  • Line coverage should not penalize the overall coverage score.
  • Either exclude these methods entirely from line coverage calculations or treat them as fully covered when integration tests exercise the related system behaviour.

Current Behavior:

The @DoNotMutate annotation ensures mutation coverage is 100%, but line coverage remains low because:

  • Integration tests do not map directly to specific lines within the annotated methods.
  • The framework still includes these methods in line coverage calculations.

Example:

package io.example;

import com.groupcdg.pitest.annotations.DoNotMutate;

public class Example1 {

    public String methodCoveredByTests() {
        return "This method is covered by tests.";
    }

    @DoNotMutate
    public String methodNotCoveredByTests() {
        return "This method is NOT covered by tests.";
    }
}

The mutation coverage would be 100% but line coverage is 50% which I think it not What is the aim of it? Am I somehow mistaken? Thanks for your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant