Cobertura showing wrong line coverage
Asked Answered
G

1

7

I see a strange cobertura report. It says that line number 89 (see screenshot)

siteMapItems = getItemFromPage(navParentPage, 0);

is executed once, but the method called on this line (getItemFromPage) shows no line coverage. I have also added logs in the method and i also see logs being printed during execution of unit test case.

What could be the reason of this strange report? Its not making sense to me.

enter image description here

Gendron answered 19/2, 2018 at 19:20 Comment(7)
It seems to me that an exception is getting thrown when line 90 is executed by the test. Maybe there is a bogus "catch (Exception e) {}" somewhere?Chino
@Rogério: No, there is no catch (Exception e ..) code anywhere. Also, if you see line 122 (LOG.info...). The logs get printed correctly.Gendron
If no exception is ocurring, I see no reason for the red lines... Maybe it's some bug in the Cobertura tool? If possible, you could try a different tool, such as JaCoCo.Chino
Can you upload a repro case somewhere?Beamon
Probably you only need to clean the project(delete all generated files, classes, etc) and then compile it again. Finally run the test again.Isabellaisabelle
@Gendron were you able to find the root cause for this issue? I'm also facing the same.Gynaecomastia
@Coder: No, never found solution, seems like a issue with cobertura.Gendron
R
0

Occasionally this kind of desynchronization issues arise from mismatch of java files and class files. Check if cobertura is scanning right class file.

Renata answered 1/3, 2018 at 9:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.