LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems using Clusters or Arrays of Clusters with Unit Test Framework

Solved!
Go to solution

Hi All
I am having problems setting up some unit tests with a complex control.  The control is a Cluster of Arrays of Clusters of Arrays etc.  When I start creating the test, the Unit Test Framework will recognise the control's structure.  But when I resize the first array, the structure of the control is no longer recognised and I can no longer access all elements in the control.  See attached screen shots 1 and 2, as well as attached code to see what is happening with the Display Data Store.vi. I have tried to ensure that there are no special characters in the control, and I have even removed all spaces too. I am using LabView 2014.
I would appreciate if someone help me understand how to get the Unit Test Framework going for complex controls such as these.

Message 1 of 8
(3,697 Views)

You need to use a "Setup" VI to create the values for those programatically.  Create a new VI, copy the control onto it as an Indicator wired to the connection pane.  Then either make the value you want the default value, or have it programatically generate the value you want on the block diagram and wire it to the indicator.

 

You can set it up on the "Setup\Teardown" menu of the Test Properties window.

0 Kudos
Message 2 of 8
(3,659 Views)

To use a Setup VI, logically the input to the setup VI would be the same control, and thus the same issue.  Also I would like the same VI to be in the setup and teardown, so I can Erase Data (setup) Store Data (VI Under Test), and Check Data Storage (Teardown VI).

Is there a reason that the Unit Test Framework will not work with complex controls, I have had this issue many times before?

 

 

0 Kudos
Message 3 of 8
(3,651 Views)

You misunderstand.  The setup VI would have no inputs.  You design the VI entirely outside of the Unit Test environment.  You set the values the setup outputs entirely outside of the Unit Test environment.  When you're done with it, you'll just set the Unit test up such that the input to your array/cluster/array/cluster control comes from the setup VI.

0 Kudos
Message 4 of 8
(3,649 Views)

I understand now what you mean.  That really is not a very practical solution, that would mean I would make many Constant VIs to run the testing over my application.  I would end up with more VIs to run the unit test than to run the application.

Is there not a way to make the Unit Test Framework work correctly?  I was hoping that I could adjust the naming of the controls to fix the issue, but I cannot find an issue with the naming.

0 Kudos
Message 5 of 8
(3,646 Views)

I admit it's not an ideal solution but as far as I know it's the only one.

 

Remember that you can re-use the setup VI, so you can make one setup VI that provides outputs to as many VIs under the unit test as you can fit (either by having them use the same data set for their test if the data structure is the same, or by wiring up tons of different terminals on the connector pane).

0 Kudos
Message 6 of 8
(3,641 Views)
Solution
Accepted by topic author stuart_chapman

I have received support from NI on this issue and wanted to share the solution.

 

If the controls and indicators with complex Cluster of Array have the arrays initialised to not be empty, then Unit Test Framework will work OK.  Thus the lowest level array should be set with a default value.  Set this should be set as the default value (Data Operations / Make Current Value Default).  This must be done at the highest level of the control, and you do not need to do this for each level in the control's structure.

Note that if you make a type def for the control, then how you put that  on the front panel of the VI will affect if the Default Value carries acros to the VI.  Drag and Drop from the Project will carry the Default Value across, but adding a control from the Control Palette / Select a Control will not carry across the default value.

0 Kudos
Message 7 of 8
(3,571 Views)

This doesn't seem like a solution at all.  I don't want my VI to have a default value - uninitialized/unconnected (or an empty array) should be a perfectly valid default, and I should not have to set another one just to satisfy the unit test framework.

 

What'd driving me bananas is the UI makes it look like it should work.  For the inputs in question, I see what looks like an array.  I can resize the array to 1.  In some cases, though, I can set values; in other cases I can't.  I can't figure out what is going on.

 

Look at the attached example.  Tags and IntValues are both basically the same ... well, one is an array of cluster (string,string) and the other is an array of cluster (string, int).  I can set one but not the other - with no setup vi required.

 

It's just remarkably inconsistent .... why?

 

wz2b_0-1601328274757.png

 

0 Kudos
Message 8 of 8
(2,026 Views)