|Download Help (Windows Only)|
A test case contains a set of input values, expected values, and comparison types that LabVIEW uses to check the VI under test for functional correctness. Each .lvtest file contains at least one test case. When you execute a test, LabVIEW runs the VI under test by using the input values you specified for each test case in the .lvtest file. LabVIEW then compares the resulting values with the expected values by using the comparison types you specified.
The LabVIEW Unit Test Framework Toolkit provides the following ways to configure test cases.
|Note LabVIEW lists the controls and indicators from the VI under test on the Test Cases page. If the Input/output values setting on the Unit Test Framework page of the Project Properties dialog box is Include controls and indicators from connector pane, make sure you select a connector pane pattern and assign the terminals for the VI under test.|
The following figure shows an example of entering the input values, expected values, and comparison types for a test case.
In the previous figure, the input values are 8 and 10, the expected value is 100, and the comparison type is <. When you execute this test, LabVIEW uses 8 and 10 as input values for the VI under test and compares the resulting value with 100. If the resulting value is not less than 100, test results show this test as failed.
LabVIEW displays the following data types as binary data or flattened data.
LabVIEW represents these data types by using [...] on the Test Cases page. You cannot edit these data types on the Test Cases page. However, you can configure the input and expected values of these data types by using the front panel of the VI under test, accessible by clicking the Export Values to VI button, and importing the updated values from the VI under test to the current test case.
You also can configure the input and expected values of these data types by using setup and teardown VIs. When you configure a test to run setup and teardown VIs, LabVIEW lists the controls and indicators of the setup and teardown VIs on the Test Cases page. You can configure the inputs of the setup VI before passing the data to the VI under test. Likewise, you can configure the outputs and comparison types of the teardown VI after accepting the outputs of the VI under test.
The following figure shows an example of configuring the input and expected values of setup and teardown VIs.
In the previous figure, the VI under test contains a LabVIEW class data type input, whose value assembles in the setup VI. The String input in the setup VI is a data member of that LabVIEW class. By setting the input value of the setup VI, you know the input value of the data member of the LabVIEW class. Likewise, the VI under test contains a LabVIEW class data type output, whose value disassembles in the teardown VI. By setting the expected value and comparison type of the teardown VI, you can compare the resulting value of the data member of the LabVIEW class.
Refer to the labview\examples\Unit Test Framework\LabVIEW Class\LV Class.lvproj for an example that demonstrates how to test VIs that use LabVIEW classes.