Unit Testing Group

cancel
Showing results for 
Search instead for 
Did you mean: 

Best Practice for testing a VI?

MikeeB wrote:

...I am struggling for space on the connector pane and having the extra input that does nothing other than pass a name through doesn't look good on the test report.

Note: you don't need an extra input on your connector pane - just an extra control on your front panel. It's a little known (and super cool) feature where the NI UTF can manipulate controls directly on your front panel, without the need to go through the VI under test's connector pane (and that's how Fab's unit tests did it in the example above).





Copyright © 2004-2023 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
Message 11 of 17
(903 Views)

btw, really enjoying this example Big thanks to Fab for setting up this group - this is fun!





Copyright © 2004-2023 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
Message 12 of 17
(903 Views)

Christopher Relf wrote:

Note: you don't need an extra input on your connector pane - just an extra control on your front panel. It's a little known (and super cool) feature where the NI UTF can manipulate controls directly on your front panel, without the need to go through the VI under test's connector pane (and that's how Fab's unit tests did it in the example above).

Actually, I did have the control connected as an optional input in the connector pane... I learned something new

Glad you are liking this group. 

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
Message 13 of 17
(903 Views)

Christopher Relf wrote:

FabiolaDelaCueva wrote:

Actually, I did have the control connected as an optional input in the connector pane... I learned something new

Oh wait, maybe that's what I'm thinking of...

No, you are correct, I just tried it. I disconnected the terminal from the connector pane and ran the test again and it did work. I did not try creating it from scratch though.

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 14 of 17
(903 Views)

FabiolaDelaCueva wrote:

Actually, I did have the control connected as an optional input in the connector pane... I learned something new


I just tried it. I disconnected the terminal from the connector pane and ran the test again and it did work. I did not try creating it from scratch though.

So the secret is out: if you have a front panel item (control or indicator) that's on the connector pane, the UTF will recognize it. If, at a later stage, you take it off the connector pane, UTF will continue to recognize it. The trick is that you need to put it on the connector pane for it to show up in UTF in the first place.

Although this may sound like a bug, it's actually useful for setting/reading FP items that you might normally set through loosely-typed access. The bug is that we have to put things on the connector pane in the first place





Copyright © 2004-2023 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 15 of 17
(903 Views)

FabiolaDelaCueva wrote:

No, you are correct, I just tried it. I disconnected the terminal from the connector pane and ran the test again and it did work. I did not try creating it from scratch though.

Actually, after you changed the VI under Test (like disconnectting the terminal from connector pane), to keep consistent the VI and lvtest file, you need to update the lvtest file by clicking the Update button manully.

Then that terminal will disappear from lvtest file.

Update Button.png

Besides, if you want to include controls and indicators from FP instead of connector pane, there is one configuration you can use.

Test Properties window: Advanced page -> Configuration -> Input/output values (this setting is only for this lvtest file)

"Include controls and indicators from connector pane" is its default value. You can change it to "Include controls and indicators from front panel".

InputOutputValues.png

If you want to make it available to the whole project, please go to Project Properties windows, then Unit Test Framework page -> Test Creation part -> Cofiguration -> Input/output values.

After you change this setting, the lvtest file created later will inherit its value.

Message 16 of 17
(903 Views)

Zhenfang wrote:

Actually...

Excellent post Zhenfang - thanks for the clarification and tips!





Copyright © 2004-2023 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 17 of 17
(903 Views)