03-09-2009 03:08 PM
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.
Solved! Go to Solution.
03-09-2009 10:22 PM
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)
03-09-2009 10:32 PM
I assume I am using the release framework. It came with my SRL. Unit Test Framework 1.0.
03-10-2009 12:07 AM
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
03-10-2009 02:27 PM