2
votes

I am using Cobertura for code coverage of my Java code using maven. When the reports are generated, I found out that there is no coverage generated for Interfaces.java. While going through the logs, I found below:

[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Data file does not contain instrumentation information for the file com/example/Interface.java. Ensure this class was instrumented, and this data file contains the instrumentation information.

[file name mocked up]

Please let me know the reason for this. How can I have code coverage for interfaces in java.

Thanks

1
No experience with the given tool, but in general interfaces don't have any code, thus there is no possibility of instrumentation. Instead, instrument all classes that implement that interface.Tassos Bassoukos
Thanks @TassosBassoukos ..!Ayush
@TassosBassoukos in java8 interfaces can contain method implementations: docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.htmlerosb
@erosb I know, hence the "In General...".Tassos Bassoukos
I've asked a similar question for a concrete and major issue regarding Frameworks and Java 8, based on interfaces and not on implementations. stackoverflow.com/questions/33608075/…Saad Benbouzid

1 Answers

0
votes

As commented by Tassos Bassoukos, Interfaces don't have any code, thus there is no possibility of instrumentation. Instead, instrument all classes that implement that interface. So, cobertura will not be able to show code coverage for interfaces, and skip the interfaces.java files.