How can I get full coverage on class of static utility methods?

Consider the following minimal class:

public abstract class UtilityClass {
    private UtilityClass() {}
    public static void utilityMethod() {}
}


When I run the tests with coverage, the empty constructor always comes up as not covered:
  • it doesn't matter if I mark the class abstract
  • it doesn't matter if I mark the constructor private or not define it at all


Is there a way to get IDEA report 100% coverage of this class (other than the silly solution of testing the empty constructor)?

2 comments
Comment actions Permalink

please vote for https://youtrack.jetbrains.com/issue/IDEA-26988.

Strictly speaking, your class is never initialized -> you can't reach 100% coverage.

Thanks,
Anna

0
Comment actions Permalink

Well, I should be able to get 100% coverage of the code that can actually get called. The empty constructor in the bytecode is dead code. Come on, it's called IntelliJ for a reason :-)

0

Please sign in to leave a comment.