JaCoCo measures test coverage based on the percentage of bytecode that was actually executed. Declaring a static final primitive or String constant does not generate bytecode to execute, it is just a record inside the constant pool. The only bytecode you have is an implicit default constructor, usually like this:
aload_0 invokespecial Object.<init> return
Therefore, when you do not name it, you have 0%, if you name it, you have 100%.
My suggestion is to ignore this problem. You should not try to achieve 100% coverage, no matter what. In the end, this does not guarantee anything: even 100% code can contain serious errors.
source share