Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Test Cases (Unit Test Framework Toolkit)

LabVIEW 2013 Unit Test Framework Toolkit Help

Edition Date: June 2013

Part Number: 372584F-01

»View Product Info
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.

  • You can configure test cases interactively by using the Test Cases page of the Test Properties dialog box. For each test case, enter the input values, expected values, and comparison types for each control and indicator of the VI under test.
    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.
  • You also can configure test cases interactively by exchanging values between the VI under test and the Test Cases page. This method allows you to configure the input and expected values by using the front panel and then importing the values to the Test Cases page. You also can export values from a test case to the VI under test.
  • You can configure test cases by editing .lvtest files.

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.

  • Picture
  • Array
  • Variant
  • Digital waveform
  • Dynamic data
  • Refnum
  • External data
  • LabVIEW class instance

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.

Related Information

Assigning Terminals to Controls and Indicators

Exchanging Values Between the VI under Test, Setup VI, Teardown VI, and the Test Cases Page

Flattened Data

Selecting a Connector Pane Pattern

Setup and Teardown VIs


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit