Hi Kumar,

there can be a couple of reasons, we documented the common ones in the 
documentation:

What can cause different class ids?

Class ids are identical for the exact same class file only (byte-by-byte). 
There is a couple of reasons why you might get different class files. First 
compiling Java source files will result in different class files if you use a 
different tool chain:

Different compiler vendor (e.g. Eclipse vs. Oracle JDK)
Different compiler versions
Different compiler settings (e.g. debug vs. non-debug)
Also post-processing class files (obfuscation, AspectJ, etc.) will typically 
change the class files. JaCoCo will work well if you simply use the same class 
files for runtime as well as for analysis. So the tool chain to create these 
class files does not matter.

Even if the class files on the file system are the same there is possible that 
classes seen by the JaCoCo runtime agent are different anyways. This typically 
happens when another Java agent is configured before the JaCoCo agent or 
special class loaders pre-process the class files. Typical candidates are:

Mocking frameworks
Application servers
Persistence frameworks

https://www.jacoco.org/jacoco/trunk/doc/classids.html 
<https://www.jacoco.org/jacoco/trunk/doc/classids.html>

Regards,
-marc

> On 10. Feb 2021, at 08:42, Kumar Dp <[email protected]> wrote:
> 
> Hi Marc,
> 
> Thanks for the information.
> 
> We have deployed wars and jars in the weblogic server and they are of the 
> same version on both hosts.
> 
> We run our UI test and collect the code coverage data using below java option 
> on both hosts
> 
>  
> -javaagent:/u01/jacoco/lib/jacocoagent.jar=destfile=/u01/jacoco/dump/jacoco.exec,classdumpdir=/u01/jacoco/dump/class,output=file,address=,includes=apps.applcore.*
> 
> 
> Could you please elaborate more on this?
>  If you want to combine test runs from different hosts you must make sure 
> that you deploy the same version to both of them.
> 
> I tried the below approach, but ended up getting the below message. So I 
> wonder how to make sure that I pass the same version in both apart from 
> passing the jar which has the classes. But I got the message as "data does 
> not match"
> 
> java -jar jacococli.jar report /u01/jacoco.exec --classfiles 
> /u01/Preferences.jar --csv /u01/hash/mycsv.csv --html /u01/hash/ --name "Code 
> Coverage"
> [INFO] Loading execution data file /u01/jacoco.exec.
> [WARN] Some classes do not match with execution data.
> [WARN] For report generation the same class files must be used as at runtime.
> [WARN] Execution data for class apps/pref/wrapper/UserPreference does not 
> match.
> [WARN] Execution data for class apps/pref/wrapper/PreferencesWrapper does not 
> match.
> [WARN] Execution data for class apps/pref/wrapper/PreferencesUtil does not 
> match.
> [INFO] Analyzing 31 classes.
> 
> 
> Thanks,
> Kumar
> 
> On Wed, Feb 10, 2021 at 11:22 AM Marc Hoffmann <[email protected] 
> <mailto:[email protected]>> wrote:
> Hi Kumar,
> 
> if it two different versions of the same class JaCoCo has no chance to merge 
> the coverage data from both. Imagine test with version A has full coverage on 
> a method but version B has the same method with an additional branch and no 
> coverage. What should be the merged coverage report?
> 
> If you want to combine test runs from different hosts you must make sure that 
> you deploy the same version to both of them.
> 
> Regards,
> -marc
> 
>> On 10. Feb 2021, at 06:28, Kumar Dp <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Thanks Evgeny for your reply. Please help with below queries,
>> 
>> Here is my requirement and want to generate report by merging the two 
>> different runs on two different hosts
>> 
>> Run1 on Host1:
>>  ->  
>> -javaagent:/u01/jacoco/lib/jacocoagent.jar=destfile=/u01/jacoco/dump/jacoco.exec,classdumpdir=/u01/jacoco/dump/class,output=file,address=,includes=apps.applcore.*
>> - > Class files dumped for tests 
>> DescriptiveFlexfieldTag.2419d92cd2c6a871.class and 
>> ConvertNumberTag.37bfad455e453d93.class
>> 
>> Run 2 on Host2 :
>>  ->  
>> -javaagent:/u01/jacoco/lib/jacocoagent.jar=destfile=/u01/jacoco/dump/jacoco.exec,classdumpdir=/u01/jacoco/dump/class,output=file,address=,includes=apps.applcore.*
>> - > Class files dumped for tests 
>> DescriptiveFlexfieldTag.49dc0cd2912591ec.class and 
>> ConvertNumberTag.d7c0cf501f15a429.class
>> 
>> I  merged multiple exec files collected from HOST and HOST2 into a new one 
>> using java -jar jacococli.jar merge
>> 
>> Now when I try to generate report using below command, I'm getting "Can not 
>> have same class" issue.
>> 
>> java -jar jacococli.jar report /scratch/jacoco/dump/jacoco/dest/merged.exec 
>> /scratch/dump/jacoco.exec --classfiles 
>> "/scratc/jacoco/dump1/jacoco/classes/" --classfiles <classes from HOST1> 
>> --classfiles <classes from HOST2> --csv /scratch/final_report/mycsv.csv 
>> --html /scratch/final_report --name "Code Coverage"
>> 
>> Hence I removed or excluded classes from HOST2 and generating report using 
>> below command,
>> 
>> java -jar jacococli.jar report /scratch/jacoco/dump/jacoco/dest/merged.exec 
>> /scratch/dump/jacoco.exec --classfiles 
>> "/scratc/jacoco/dump1/jacoco/classes/" --classfiles <classes from HOST1>  
>> --csv /scratch/final_report/mycsv.csv --html /scratch/final_report --name 
>> "Code Coverage"
>> 
>> My query is, 
>> 
>> - Will I be able to still achieve the right code coverage? Since I have 
>> excluded the classes from HOST2. 
>> 
>> Referring below FAQs in the doc 
>> https://www.eclemma.org/jacoco/trunk/doc/classids.html 
>> <https://www.eclemma.org/jacoco/trunk/doc/classids.html>, 
>> 
>> What is the disadvantage of JaCoCo class ids?
>> The fact that class ids identify a specific version of a class causes 
>> problems in setups where different classes are used at runtime and at 
>> analysis time.
>> 
>> What happens if different classes are used at runtime and at analysis time?
>> In this case execution data cannot be related to the analyzed classes. As a 
>> consequence such classes are reported with 0% coverage.
>> 
>> 
>> Thanks and Regards,
>> Kumar
>> 
>> On Tuesday, February 9, 2021 at 4:13:50 PM UTC+5:30 Evgeny Mandrikov wrote:
>> You're missing
>> 
>> --classfiles
>> 
>> for the second directory
>> 
>> "/scratch/jacoco/dump2/class/"
>> 
>> i.e.
>> 
>> java -jar jacococli.jar report /scratch/jacoco/dump/jacoco/dest/merged.exec 
>> /scratch/dump/jacoco.exec --classfiles 
>> "/scratc/jacoco/dump1/jacoco/classes/" --classfiles 
>> "/scratch/jacoco/dump2/class/" --csv /scratch/final_report/mycsv.csv --html 
>> /scratch/final_report --name "Code Coverage"
>> 
>> On Tuesday, February 9, 2021 at 11:40:57 AM UTC+1 Kumar Dp wrote:
>> I have two different test execution which resulted in two code coverage file 
>> (*.exec) and classes got dumped to two different folders.
>> 
>> Below command is failing when I run the report command using java cli mode.
>> 
>> java -jar jacococli.jar report /scratch/jacoco/dump/jacoco/dest/merged.exec 
>> /scratch/dump/jacoco.exec --classfiles 
>> "/scratc/jacoco/dump1/jacoco/classes/" "/scratch/jacoco/dump2/class/" --csv 
>> /scratch/final_report/mycsv.csv --html /scratch/final_report --name "Code 
>> Coverage"
>> [INFO] Loading execution data file  
>> /scratch/jacoco/dump/jacoco/dest/merged.exec  .
>> [INFO] Loading execution data file  /scratch/dump/jacoco.exec  .
>> [INFO] Loading execution data file /scratch/kumar/jacoco/fnd/dump/class.
>> Exception in thread "main" java.io.FileNotFoundException:  
>> /scratch/jacoco/dump2/class  (Is a directory)
>>      at java.io.FileInputStream.open0(Native Method)
>>      at java.io.FileInputStream.open(FileInputStream.java:195)
>>      at java.io.FileInputStream.<init>(FileInputStream.java:138)
>>      at 
>> org.jacoco.cli.internal.core.tools.ExecFileLoader.load(ExecFileLoader.java:72)
>>      at 
>> org.jacoco.cli.internal.commands.Report.loadExecutionData(Report.java:99)
>>      at org.jacoco.cli.internal.commands.Report.execute(Report.java:83)
>>      at org.jacoco.cli.internal.Main.execute(Main.java:90)
>>      at org.jacoco.cli.internal.Main.main(Main.java:105)
>> 
>> 
>> Please suggest how to pass multiple class path directories for report 
>> generation.
>> 
>> I'm following the instruction from 
>> https://www.jacoco.org/jacoco/trunk/doc/cli.html 
>> <https://www.jacoco.org/jacoco/trunk/doc/cli.html>,
>> where it is mentioned that  "--classfiles <path> location of Java class 
>> files" is multiple.
>> 
>> Regards,
>> Kumar
>> 
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <mailto:[email protected]>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/dd11c97d-ba00-4ea8-a33a-70222cf2eb10n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/dd11c97d-ba00-4ea8-a33a-70222cf2eb10n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/jacoco/vLiZkw8kq9c/unsubscribe 
> <https://groups.google.com/d/topic/jacoco/vLiZkw8kq9c/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/BCE468EB-1289-4619-A7A4-221B18CA49AD%40mountainminds.com
>  
> <https://groups.google.com/d/msgid/jacoco/BCE468EB-1289-4619-A7A4-221B18CA49AD%40mountainminds.com?utm_medium=email&utm_source=footer>.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/CAE7FgZmWjbY0jb3QddX3FkU9hXcRAq%3DsFuWZfN6KnDWVGSjBDg%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/jacoco/CAE7FgZmWjbY0jb3QddX3FkU9hXcRAq%3DsFuWZfN6KnDWVGSjBDg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/CB7D0AC3-4DBC-4802-A076-2FA816305012%40mountainminds.com.

Reply via email to