The Unit Test Framework is a tool for LabVIEW that can be used to automate unit testing, requirements-used validation and regression testing of Vis.
    A unit test us strictly something that ‘exercises’ or runs the code under test.

    First.Creating a Test for a LabVIEW VI
    To create a test in LabVIEW using the Unit Test Framework, right click on the VI under test in the Project Explorer and move your cursor over the ‘Unit Tests’ menu item. Select ‘New Test’ to create a new file on disk with an .lvtest extension (see figure 1).
    image.png
    Second.Defining Test Vectors
    Vis, like a function call in text-based programming languages,have inputs and outputs.When a unit test is performed in LabVIEW, a known set of inputs is supplied to the VI. These inputs are paired with a pre-determined set of expected outputs to define a ‘test vector’.The output of the VI after execution is then cpmpared with what was expected to generate the results. The Unit Test Framework allows the creation of these tests without any modification to code.
    image.png

    1. Test cases can be specified in a number of different

    ways using the Unit Test Framework.The most mechanism is the dialog that appears in LabVIEW if you double click on an .lvtest file in the Project Explorer. In the dialog that appears,select ‘Test Cases’ from the list of categories to specify the inputs and expected outputs. By default,you can specify input values for all controls attached to the connector pane and specify expected output values for any indicators tied to the connector pane.
    image.png

    1. If you

    have additional(extra) inputs that are not attached to the connector pane,or if you wish to evaluate inputs as outputs, you may configure this from the advanced category under the configuration options. Outputs may also be excluded from comparison by deselecting the checkmark next to the line in the Test Case.
    image.png
    As with any programming language, inputs that are unbounded have an infinite number of values. For this reason, inputs are typically selected that represent multiple values from a certain range, but completely exhaustive testing may not be possible.

    One .lvtest file can contain multiple test cases. For example, you might create a test that evaluated the VI’s performance when it received incorrect input; however, there are likely numerous combinations of inputs that fall under this category and therefore would be a part of the same test, but each of which would require the definition of a new test case. To add additional test cases, click ‘New’ from the ‘Test Cases’ Category.
    image.png

    Thirdly,advanced test configuration options.
    VIs that have state or require programmatic configuration may require the use of ‘setup’ and ‘teardown’ VIs in order to perform testing. The output of the setup VI can be passed to the VI under test. This is valuable if you need to programmatically generate a complex input, such as a large waveform, or perhaps prepare a file or database for testing (see figure 6). It could also be used to pass in a reference to a file or object that you wanted the VI under test to use.
    image.png

    Additionally, filters can be defined in order to only run tests that meet a certain priority or that have not been ran since a certain date.
    In order to avoid a scenario in which a developer is creating their own tests that are easily passed, due diligence must be given to requirements definition. For software engineers, the task of gathering requirements and defining specifications for code behavior is the first in a series of steps for software development. It is typically through this process that effective tests are defined and the expected behavior of code is determined.
    Indicidual Tests-right click on the test in the Project Explorer and select ‘run’
    By VI Under Test – rick click on the VI you wish you test, and navigate to ‘Unit Tests > Run’
    Tests In a Folder – right click on the folder and select ‘Unit Tests > Run’
    All Tests in the Project Explorer – Click on ‘Run Unit Tests’ in the toolbar of the Project Explorer
    *Programmatically - Use the VIs on the Unit Test Framework Palette.

    image.png