Unit Testing VI Properties

Have you ever set a reentrant VI to non-reentrant in order to facilitate debugging, only to forget to set the VI back to reentrant when you’re done?  This mistake can be very tough to debug, as the difference in behavior (between reentrancy and non-reentrancy) can be very subtle.  The same is true for other VI Settings (e.g. the subroutine Execution Priority setting).  The point is, during development you may change some VI Properties in ways that make sense for debugging, but will cause bugs in your application if left that way.  Forgetting to reset them to their correct values can cause huge headaches when your software is delivered (or worse, long after it’s delivered).

How can you ensure that important VI Settings are correct for specific VIs, prior to deployment?

That’s easy, just create a unit test (using VI Tester) that validates the required setting, as shown below:

Unit Test for Required Reentrancy

Unit Test for Required Reentrancy

The VI that performs the reentrancy check, passIfReentrant.vi (shown below), is one that you probably haven’t seen before, since it’s not delivered as part of VI Tester.

passIfReentrant.vi

passIfReentrant.vi

If we look at the block diagram, shown below, we’ll see that it’s not very complicated:

passIfReentrant.vi Block Diagram

passIfReentrant.vi Block Diagram

This VI simply checks the reentrancy and outputs a descriptive test failure message explaining the details of the failure.  When we run our unit tests, prior to building and deploying our application, VI Tester catches the problem and shows us exactly where to look.

VI Tester showing failure

VI Tester showing failure

If you’d like to add reentrancy tests to your LabVIEW application’s unit test suite, you can download passIfReentrant.vi here:

If you have ideas for other common, reusable VI Settings (or other) tests, please share your ideas by leaving us a comment below.

How to get VI Tester

VI Tester is available on the VI Package Network. If you’re already a VI Package Manager user, just click the “Check the VI Package Network for Available Packages” button in the VIPM window. VIPM will notify you that VI Tester is available, and you can simply tell VIPM to download & install it for you.

check-network-for-pkgs

Check the VI Package Network for Available Packages

If you’re not already a VI Package Manager user, what are you waiting for? VI Package Manager lets you take control of your reusable VIs, and is also the best way to put all the great tools from JKI Labs, OpenG.org, and the whole VI Package Network into your palettes!

For more information about VI Tester, visit jkisoft.com/vi-tester.

This entry was posted in VI Tester. Bookmark the permalink.

6 Responses to Unit Testing VI Properties

  1. Very good example on how to use proficency your VI Tester. Another use case example could test VI for presence of breakpoints.
    Just an ipotesis, can a set of test run automatically at deploy\compile time? This could be very usefull.
    Another point is how JKI VI tester relates with NI LabVIEW Unit Test Framework Toolkit?

    Ciao,
    Alessandro

  2. Omar Mussa says:

    Another good use case for testing VI Properties is to validate that specific string data is present in the VI Description.

  3. Omar Mussa says:

    Alessandro – you can run tests automatically through the VI Tester programmatic API. VI Tester is an xUnit based test framework that is completely separate from NI’s test vector based UTF. You can find more about VI Tester by visiting: http://jkisoft.com/vi-tester

  4. Jim Kring says:

    Alessandro: As Omar mentioned, you can run tests programmatically, now. If you incorporate this as a step in your One Click Build, then you can run your tests before building your EXE.

  5. Omar and Jim VI tester + One Click Build could be a amazing. here i’m trying to use Agile methods and for sure Test Driven Development and Incremental Releases are what i consider the most valid methods, your tool can help to use this methods, definitivelly i’ll give it a try.

  6. Jim Kring says:

    Alessandro: Please, let us know about your progress and if you have any questions about implementing a VI tester + One Click Build solution for your applications.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>