Typically, if I have something (a microservice) that is 100% covered both for lines and branches, neither JaCoCo or Cobertura will show it properly unless I do some things. Here are some examples of the type of things I have to do:
* Re-order methods in a class. This can make as much as 15% or more difference in the overall code coverage. * Change to static typing on some returns from methods (but not all). This can make a large difference. * Some refactors help coverage. In particular, turning “if’s” into types can help since the coverage tools usually show way more branch options than the expressions would indicate. For instance, if you had something like “if (x == y)” that might say there are something like 13 possible branch options due to odd generated code related to the “if.” I have quite a few projects where I’ve gotten Cobertura to correctly show 100% line/branch coverage and many with it showing 99% so I set my build thresholds to around 97 or 98 to make sure I catch anything changing that but it takes some time to arrange things to be correctly measured. Michael Corum VP, Technical Architecture Solutions RGA Reinsurance Company 16600 Swingley Ridge Road Chesterfield, Missouri 6301701706 T 636.736.7066 www.rgare.com From: Paul King <pa...@asert.com.au> Reply-To: "users@groovy.apache.org" <users@groovy.apache.org>, "pa...@asert.com.au" <pa...@asert.com.au> Date: Thursday, June 20, 2019 at 4:15 PM To: "users@groovy.apache.org" <users@groovy.apache.org> Subject: Re: Code coverage tools? External e-mail. Use caution! / Courriel externe. Faites attention! ________________________________ Groovy has done a lot of work recently to mark generated methods with an @Generated annotation. We have other generated methods which are synthetic methods. I know JaCoCo has been making changes to ensure that such methods aren't included in coverage analysis. I am not sure whether Cobertura has done any updates along those lines. It did appear for a while that activity on Cobertura was decreasing but I notice there was some activity a few months ago. It is perhaps worth asking that community about whether they have or can consider making similar changes, otherwise perhaps switching to JaCoCo might be the way to go. Cheers, Paul. On Fri, Jun 21, 2019 at 3:02 AM Sean LeBlanc <sean.lebl...@icd-tech.com<mailto:sean.lebl...@icd-tech.com>> wrote: What are people using currently to get accurate code coverage from new(ish) versions of Groovy? We are on 2.4.10 and I see similar issues as what this thread is talking about: https://github.com/cobertura/cobertura/issues/184<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_cobertura_cobertura_issues_184&d=DwMFaQ&c=5uPv0lijNz76uSeaN5P0Zw&r=rh3Qrw7azSI9xkZZ-a8EEw&m=FjAAb8X6cAC-Y7QDFj98g3FXEKwft7b3XMPHfp053pk&s=ETpCgOjg6J5tjlse1mis1tpk5M2H1v2Hl4_xA0qPf4g&e=> Does anyone have good experiences with getting more accurate code coverage numbers with Groovy > 2.0.8? And what route did you take?