Jump to content

Code coverage metrics


Recommended Posts

I was reading through one of NI's documents where they discussed code coverage. Here's a diagram from the article:

post-7603-124923071063_thumb.png

How in the world does someone look at that and claim they have 50% code coverage? I look at that and see that at best you've got 40% coverage. 16% if you're measuring execution paths instead of executed code. What gives?

Edited by Daklu
Link to comment

I think the figure ist just an illustration of the outcome of a specific test. So I guess it is not self-explaining.

But if you imagine that only 50% of posible data paths in the code is tested and the code coverage will be multiplicative thru the hierarchy you will easily see that you need lots of test vectors to get a sufficient high code coverage for the overall code.

Link to comment
...16% if you're measuring execution paths instead of executed code.

"Code Coverage" is a a relative term smile.gif and it doesn't really mean execution paths (that's cyclomatic complexity, which is very difficult to conceptualize with any programming language, and LabVIEW in particular). More info here (at arond the 15 minute mark).

OK - the image is a little difficult to follow because it doesn't show that what we're actually counting here are diagrams - each of the executed pages is a diagram, and the main BD is counted a diagram, so that adds up to 3 diagrams executed. There are a total of 6 diagrams (the main BD, 2 cases in the first structure and 3 in the second), so that's a total of 3/6 = 50%. It is *not* tracing paths at the component level - it's tracing them at the diagram level. This all makes sense (it's the same method used by the VISTA Code Coverage Toolkit from oh so many years ago) - if the main BD wasn't counted, then the aggregate matrics for a whole project would be wrong.

I just got the skinny from Eli Kerry (one of the benefits of being on the ground at NI-Week 09 smile.gif ) and he gave me this - I think that the colour coding goes a long way in making it more clear:

post-181-124931465208_thumb.png

It's the green diagrams that are counted in this test case. ...and here's the coverage graphic for the 2nd test vector:

post-181-124931494684_thumb.png

  • Like 2
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.