Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Basic Code Coverage Question(Why does code coverage report such low numbers?)
Basic Code Coverage Question [message #1797439] Tue, 30 October 2018 22:57 Go to next message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
I gave the code coverage functionality in Eclipse (2018-09) a whirl today and was rather surprised by the report it generated. My class, which is a JUnit5 Test Case, has 420 lines of source code but, of course, some of those lines don't get executed as such since they are imports, comments, blank spaces, and class and method declarations. But everything else (aside from two small methods with @Disabled annotations got executed, probably around 300 lines total. So far so good.

However, when I look at the report, it says I executed only 4.2% of my code! Furthermore, it says it there were 1113 "covered instructions", 25,515 "missed instructions" and 26,628 "total instructions".

I'm baffled by this. Essentially, I think I want it to say that I executed 100% of my code, not just 4.2%, since all the statements it could actually execute (which I wanted executed) WERE executed. Also, I don't understand what it means by "instructions" and why there are so many compared to the number of lines actually in my class - and how I managed to miss so many!

Can someone kindly explain what the report actually MEANS? I want to make sure I cover all of my code and if these low numbers mean I've only scraped the surface, I need to know what else I need to do to test ALL of the code. If I *have* run all of the code as I think I have, how do I coax the report to acknowledge that with a nice 100% in the Coverage column?
Re: Basic Code Coverage Question [message #1797441 is a reply to message #1797439] Tue, 30 October 2018 23:06 Go to previous messageGo to next message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
Sorry, everyone! After posting this question, I found out what I'd done wrong. The 4.2% did not refer to my TestCase class, it referred to the whole project, consisting of all of my actual code from that project and all the test case classes I've written so far. When I drilled down a few levels into my UnitTest folder, its package, and then my specific test case class, I found that I'd executed 96% of the code in that and 100% of the code in the 21 out of 23 methods that actually executed; if I'd executed the two disabled methods, it would have reached 100% as I expected.

I hope I haven't wasted anyone's time and apologize if I have. (I suggest we leave this post here so that anyone else making the same mistake may be able to learn from my foolishness.)

I'm still hazy on one thing though: why does the report measure instructions instead of lines of code? I'm still not clear on what an "instruction" is for this coverage tool. Are we talking about bytecode instructions in the JVM?
Re: Basic Code Coverage Question [message #1797444 is a reply to message #1797441] Wed, 31 October 2018 01:55 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 872
Registered: January 2012
Senior Member

You'll likely get a more meaningful response by posting to the forum or mailing list for your coverage tool. I'm guessing you're using EclEmma?

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Feature Request?
Next Topic:JUnit question
Goto Forum:
  


Current Time: Wed Feb 26 17:29:49 GMT 2020

Powered by FUDForum. Page generated in 0.02840 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top