I have a Gradle project with the JaCoCo plugin applied to it. When I run my tests and create a jacocoTestReport I get this classes not matching error
[ant:jacocoReport] Classes in bundle 'e-services' do no match with execution data. For report generation the same class files must be used as at runtime.
[ant:jacocoReport] Execution data for class eservices/model/persistence/Event does not match.
The classes should match as I'm doing a clean -> build -> test locally. I suspect the mismatch comes from the fact that I'm using jackson.map.ObjectMapper to create an object from a JSON and somehow this causes the classId stored in jacoco's .exec file not match the compiled class id.
My test uses the Event class extensively and still I get 0% coverage due to class mismatch:
import eservices.model.persistence.Event;
event = mapper.readValue(json, Event.class);
event.setTenId(TenIds.getInternalId());
Is there a way to get coverage from this scenario?
This is a JaCoCo Known limitation as JaCoCo relies on the checksum of the runtime bytecodes matching the checksum of the bytecodes it uses for report generation. Typically it happens when you have two libraries instrumenting bytecodes, like PowerMock and JaCoCo, or JPA and JaCoCo.
This is referenced in the following JaCoCo issue Coverage is missing a class that was in fact tested #193 and it is labeled as 'wontfix' 'known limitation'
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments