I have a webapp which makes REST calls. This webapp is bundled with cobertura instrumented classes. From the REST resource, the public service APIs are invoked using reflection (This was done to overcome some class loading issues with OSGI).
Now there is an issue with the code coverage. When i generate the cobertura code coverage report, i see that the coverage is being captured till the resource and all the reflective public method calls are ignored in the coverage.
Is there a way where we can get the coverage for the reflective methods calls as well.
Please find the code sample below
for (Method method : methods) {
if (method.getName().equals("getAbc")) {
abc= (List<Abc>) method.invoke(**service**, serviceContextInfo);
return SomeUtil.getSuccessResponse(abc, serviceContext);
}
}
The coverage is not captured from the "method.invoke" which is the core service call. And again I can see the coverage in the SomeUtil class where the response is updated.
Note: This being an OSGI environment (apache felix), the method being invoked is in a different class loader than the place where it is invoked from.