jacoco report with some files having lines not highlighted

1.3k Views Asked by At

While checking my jacoco report, I noticed some files doesn't have lines highlighted. It has the method name highlighted, but not any of the statements in the method. At the same time, other files have all the lines highlighted in either red/green which is what I was expecting. So why are some of the files in the same report doesn't have anything highlighted? I read the FAQ but it would seem if I messed something up in the report generation, none of the lines would be highlighted? When I tried generating the report with the wrong class files, all the lines would be highlighted in red. So what am I missing that's causing some of the lines to be not highlighted?

I'm using maven and am doing code coverage on a java project. thanks

class and jacoco file zip

method highlighted green but not any of the code

1

There are 1 best solutions below

1
On BEST ANSWER

Let's take a look on bytecode of a class:

javap -v UserListsComponentProvider

it shows

public void getUserShoppingListByListId(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.ws.rs.container.AsyncResponse) throws com.coupons.web.api.base.BusinessException;
...
      LineNumberTable:
        line 50: 76
    Exceptions:
      throws com.coupons.web.api.base.BusinessException

So information in bytecode about lines contains only one line for method getUserShoppingListByListId and JaCoCo shows exactly what it sees.

I guess that this happens, because you instrument and analyze classes that are weaved by AspectJ instead of instrumentation and analysis of original classes. See https://github.com/jacoco/jacoco/issues/476#issuecomment-271118961 that discusses similar issue and provides example of JaCoCo usage with AspectJ Compile-Time Weaving.