Hi Nicolas,

the question is, for which JVM you want to collect coverage for:

  1) the server code —> Use the agent on the server process

or

  2) the test client code —> use the jacoco:coverage task

In case of 1) I have serious doubts that you will get a usable coverage report 
on obfuscated byte code. Maybe meassure test coverage on the original classes?

Regards,
-marc

> On 10. Oct 2022, at 16:02, Nicolas Garcin <[email protected]> 
> wrote:
> 
> Hi Marc,
> 
> Thanks for your answer. I'll give you a bit more details because I still 
> don't understand how I can get readable results:
> The application for which I want to measure the coverage is a server. The 
> classpath of the server contains obfuscated jars. I can clearly see the 
> obfuscated classes by using the -verbose:class JVM option for the server. For 
> example, I can see:
> 
> [Loaded lib.system.datactrl.k from 
> file:/data/home/testauto/nxat/data/bamboo/datahub-build-10/datahub-build-10-agent/xml-data/build-dir/DAT-DHBB10454-UN/dist/nxdh-6.3-02-SNAPSHOT/NXDH/Soft/jar/smartsys.jar]
> 
> k is the result of obfuscation of a class called DataWriteController. The 
> server is started using 
> -javaagent:org.jacoco.agent-${jacoco.version}-runtime.jar in order to allow 
> instrumentation.
> 
> In order to test the server, we run an Ant Junit task embedded into the 
> jacoco coverage task:
> 
> <jacoco:coverage destfile="${jacoco.dest.file}" append="true" 
> enabled="${nxdh.coverage.junit}">
> <junit printsummary="true" fork="true" forkmode="perTest" dir="${basedir}" 
> showoutput="${show.output}" jvm="${JAVA_HOME}/bin/java">
> <classpath refid="test.classpath" />
> <jvmarg line="${test.jvmargs}" />
> <jvmarg line="${debug.jvmargs}" />
> <jvmarg line="${test.args}" />
> <formatter type="brief" usefile="false" />
> <formatter type="xml" />
> <batchtest todir="${test.report.dir}">
> <zipfileset src="${test.jar}" includes="testsuites/*TestSuite*.class" 
> excludes="${serial.test.suites}" />
> </batchtest>
> </junit>
> </jacoco:coverage>
> 
> The junit task has its own classpath which may contain non-obfuscated jars 
> but I guess it is used for the junit test process only, not for the server 
> under test.
> 
> After generating coverage report, I can clearly see coverage on 
> DataWriteController class. This makes me confused because I would expect to 
> see coverage on lib.system.datactrl.k, and not on 
> lib.system.datactrl.DataWriteController.
> 
> Does this make sense or do I miss something? 
> 
> Thanks a lot.
> 
> Regards,
> Nicolas
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Le lun. 10 oct. 2022 à 13:56, Marc Hoffmann <[email protected] 
> <mailto:[email protected]>> a écrit :
> Hi Nicolas,
> 
> JaCoCo works on byte code only. It doesn’t matter whether the byte code comes 
> from the compiler or obfuscator. Of you create an report on the obfuscated 
> code the result will probably not very readable though.
> 
> If you see coverage on a class “com.xxx.User” this means a class with exact 
> this name was loaded in the JVM when coverage data was collected.
> 
> Regards,
> -marc
> 
> 
>> On 7. Oct 2022, at 16:26, Nicolas Garcin <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Hi everyone,
>> 
>> Our software is written in Java and (partly) obfuscated. We're measuring our 
>> test coverage with Jacoco agent. I'm surprised to see that Jacoco manages to 
>> calculate coverage even on obfusacted code. For example, I have a 
>> com.xxx.User.class that is obfuscated into a.b.c.class. The obfuscated class 
>> is used at runtime and I can see in the coverage report some coverage on 
>> com.xxx.User.class. How is that possible ? 
>> 
>> Thanks and Regards,
>> Nicolas
>> 
>> -- 
>> 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/7dae77f8-7d63-43e2-8d10-3314a69420een%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/7dae77f8-7d63-43e2-8d10-3314a69420een%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/aF8VnY1ApyQ/unsubscribe 
> <https://groups.google.com/d/topic/jacoco/aF8VnY1ApyQ/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/61253AB6-9F91-4F6F-9F8F-A7CF00AA8A59%40mountainminds.com
>  
> <https://groups.google.com/d/msgid/jacoco/61253AB6-9F91-4F6F-9F8F-A7CF00AA8A59%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/CAL-MECNKntXMDrYuMuB8pumw_--7_ek394BQg97O4eqGgp3O1w%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/jacoco/CAL-MECNKntXMDrYuMuB8pumw_--7_ek394BQg97O4eqGgp3O1w%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/61B6A4E8-A92F-4705-8C69-EA7EA1ED1BC3%40mountainminds.com.

Reply via email to