jacoco / jacoco

:microscope: Java Code Coverage Library
https://www.jacoco.org/jacoco/
Other
4.22k stars 1.15k forks source link

Merge coverage of classes with different ids #197

Open jflefebvre06 opened 10 years ago

jflefebvre06 commented 10 years ago

Could you please add a way to skip classes's ids check ?

I have a gwt project, with ut and it tests. My first report show ut tests (I use target/classes to generate report) My second report show it tests (I use classdumpdir to generate report) My third report is an aggregate of ut and it tests. If I use target/classes my it coverage is not showed. If i use classdumpdir my ut coverage is not showed).

Is there a way to generate my aggregated report with ut and it coverage ?

marchof commented 10 years ago

Currently JaCoCo can only merge probes (exec files) which depend on the exact class version (i.e. class id). This merge is performed before the coverage is analyzed.

Another option would be to merge coverage of already analyzed coverage. The question is how the merging algorithm would look like: For example one could calculate the maximum total number of instructions/branches per line or method and the maximum numbers of covered items respectively.

marchof commented 10 years ago

@jflefebvre06 A possible workaround for your setup could be to use offline instrumentation for the it tests.

jflefebvre06 commented 10 years ago

Thanks a lot for your response I don't understand why mixing agent for ut and offline instrumentation for it will solve the problem

jflefebvre06 commented 10 years ago

I miss to mention that my it tests are based on gwt compilation

marchof commented 10 years ago

For the it you class files seems to be modified by some gtw magic before JaCoCo agent sees them for on-the-fly transformation. Otherwise using classdumpdir would not be required.

The trick with offline instrumentation is that the original classes gets instrumented before any other framework cuts in, so the classids remain the same and no need to use classdumpdir any more,

jflefebvre06 commented 10 years ago

GWT not modify the original classes (target/classes) but create new classes with it's own compilation

marchof commented 10 years ago

So I don not understand what the problem with class ids is. If you get separate classes in your it, why can't you you simply create an report on both, your compiled classes and the gwt classes?

jflefebvre06 commented 10 years ago

It is what I do. But I would like an aggregated report of UT tests an IT tests.

marchof commented 10 years ago

So what prevents you to create the aggregated report with both class file sets, from target/classes and classdumpdir destination?

jflefebvre06 commented 10 years ago

I try with the 2 filesets into but I take an error (duplicated classes)

marchof commented 10 years ago

If you get an duplicate class exception this means you have classes with the same name but in different versions. So something in your it setup does modify classes.

jflefebvre06 commented 10 years ago

It is exactly that. UT case uses target/classes : simple junit tests without GWT compilation IT cases (GWTTestCases) uses GWT compiled classes

marchof commented 10 years ago

Then you might try offline instrumentation as mentioned above.

mkobit commented 6 years ago

I think I'm running into a case where I want something like this. I've fully outlined it in https://groups.google.com/forum/#!msg/jacoco/-zTg9Bt5964/dUliK8OsAwAJ , but the gist is "coverage for source code that is compiled at runtime but is compiled multiple times"