Getting below warning and classes are not showing in code coverage:
[WARNING] Classes in bundle '<module_name>' do not match with execution data. For report generation the same class files must be used as at runtime.
[WARNING] Execution data for class <class_name> does not match.
[WARNING] Execution data for class <class_name>does not match.
[WARNING] Execution data for class <class_name> does not match.
[WARNING] Execution data for class <class_name> does not match.
[WARNING] Execution data for class <class_name> does not match.
These classes I have mentioned in preprare for test as below :
@PrepareForTest( { <class_name>.class}) @RunWith(PowerMockRunner.class) @PowerMockIgnore("jdk.internal.reflect.*")
I found below workarounds but not sure how to implement any of these :
If classes get modified at runtime in your setup there are some workarounds to make JaCoCo work anyways:
If you use another Java agent make sure the JaCoCo agent is specified at first in the command line. This way the JaCoCo agent should see the original class files. Specify the classdumpdir option of the JaCoCo agent and use the dumped classes at report generation. Note that only loaded classes will be dumped, i.e. classes not executed at all will not show-up in your report as not covered. Use offline instrumentation before you run your tests. This way classes get instrumented by JaCoCo before any runtime modification can take place. Note that in this case the report has to be generated with the original classes, not with instrumented ones.