LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How is code coverage calculated in the unit test framework

Solved!
Go to solution

I am looking for documentation on how the unit test framework calculates code coverage. 

 

I just recently installed the unit test framework and I have had mixed results with the code coverage feature.  I manually calculated all of the branch points in my vi, but the framework calculates more than I can think of, which yields a less than stellar code coverage value (51%).  Is there any documentation for how this is calculated?  I am either missing something fundamental or there is a bug with the framework. 

 

My vi consists of a for loop (with uninitialized shift registers) that runs once.  Inside the for loop is a T/F case structure that leads into an enumerated case structure with two possible cases (one of which is default)....pretty basic.  Inside one of the case structures is a for loop and the other is pass through.  For some reason the unit test framework calculates 7 "diagram run flags".  I use the "external" test harness method to call all my test cases for the vi under test, b/c frankly it was easier to use than the gui  provided.  I am not sure if this is the cause, b/c I have seen other oddities when using it, which I will save for another discussion thread.

0 Kudos
Message 1 of 5
(3,480 Views)

Are you using the release version of UTF? In release version, UTF calculates code coverage in diagram. If the VI have 7 diagrams, the result should be # of executed diagram/7 and it can't be 51%.(In beta version, it's different)

0 Kudos
Message 2 of 5
(3,439 Views)

I assume I am using the release framework.  It came with my SRL.  Unit Test Framework 1.0.

 

 

0 Kudos
Message 3 of 5
(3,436 Views)
Solution
Accepted by topic author torctech1325

Code coverage is calculated by dividing the number of diagrams the code of which was executed by the number of diagrams in your VI in total. Every VI has at least 1 diagram (the actual block diagram). Loops have one diagram each, case structures and sequences have one diagram per frame and so forth (=> from your description, your VI has at least 7 diagrams). You can double-click the diagrams that weren't executed in the Unit Test Framework Results dialog in order to display them.

 

This approach does not reflect the amount or complexity of the code that each diagram contains. We have looked into various ways of counting nodes, terminals, controls, wires and the like, which would give you a number that reflects your code more accurately. Unfortunately, none of these approaches yields values that can easily be understood without some knowledge about the inner workings of LabVIEW. We made a choice to go with a solution that is completely transparent to end users.

 

Thanks,

Herbert

0 Kudos
Message 4 of 5
(3,423 Views)
Many thanks.  That helped a lot.  It turns out the reason why I wasn't able to get 100% coverage was with my test was related to something odd with my lvtest file.  Having exhausted all leads, I removed the lvtest file from the project, deleted it and recreated it.  And....I got 100% using my test harness that was previously giving me only 51%. 
0 Kudos
Message 5 of 5
(3,398 Views)