Designing a Custom VI Analyzer Test (VI Analyzer Toolkit)
Note The VI Analyzer functionality this topic describes is available only if you install and activate the LabVIEW VI Analyzer Toolkit. Refer to the NI website for more information about the VI Analyzer Toolkit.
Select Tools»VI Analyzer»Create New Test to display the VI Analyzer Test Creator wizard. Complete each page of the wizard to generate template files for a custom test. A VI Analyzer test consists of an LLB of files that perform the following tasks when you run the test:
Test Configuration—A test configuration page, which displays in the VI Analyzer - Select Tests dialog box when you select a test to run, allows you to specify values to use in the test. For example, for a test that searches for numeric controls with a particular default value, you can use the configuration page to specify the value for which to search. A VI or global VI, a special VI that defines a global variable, serves as the configuration page.
Note If a configuration page is global VI-based, the LLB contains only a global VI you can use to pass values from the configuration page into the test. If a page is VI-based, the LLB contains a VI for the user interface and a global VI for passing values from the configuration page into the test.
Testing—Block diagram code in the main test VI checks aspects of VIs and returns data about failures. You can also configure the main test VI to highlight VIs and VI objects that cause failures.
The VI Analyzer Test Creator wizard saves test LLBs you create in the LabVIEW Data\VI Analyzer Tests directory. Before you can run the test in the VI Analyzer, you must modify each file in the test LLB. Refer to the following sections of this topic to modify each file so you can run the test.
Creating a Test Configuration Page
In test Config.vi, add any front panel controls you want to appear on the test configuration page and configure the controls if needed. To set a default value for a control, right-click the control and select Data Operations»Make Current Value Default from the shortcut menu. If the configuration page is VI-based, add code to the block diagram that controls the user interface as you interact with it.
Tip Use the system controls and indicators to create a configuration page that changes appearance depending on which platform you run the VI Analyzer.
After you add controls to the configuration page, delete the existing decoration and text from the front panel. Even if the test does not require configuration values, you still must delete these items.
To change the test description, revise the description of the test Config.vi.
Writing the Test
In the main VI in the LLB, complete the following steps to work with the template controls and indicators in the test VI.
Use the VI Refnum input to obtain a reference to the VI you want to test. Use VI server properties and methods to obtain references to objects in the VI. To find all instances of a particular object in a VI, whether on the front panel, block diagram, or in containers such as tab controls, you can use the reference with the Traverse for GObjects VI. You must enable VI Scripting before you can use the Traverse for GObjects VI.
(Optional) In the upper right corner of the configuration page global VI, click and drag the icon to the block diagram of the test VI to create a global variable you can use to access values from the configuration page.
Use the VIAnUtil Build Result Cluster VI to specify a test result message and the UID property of the object that failed. This utility VI returns the Results Data array.
Note Do not add data to the Results Data array when a test passes.
Refer to the following guidelines as you add test code to the block diagram:
Check VIs being tested to ensure they are appropriate for the test code. For example, if a test checks block diagrams for a particular object, add code to the test to account for global VIs, which do not have block diagrams.
Do not modify the connector pane of the test VI. For example, do not delete the VI Refnum, Results Data, and error out block diagram objects.
Close references to all objects except the reference to the VI being tested.
Make sure any subVIs in the test LLB have unique filenames that other tests are not likely to duplicate. For example, you can name the subVIs with a test-specific prefix.
Configuring the Test to Highlight Failures
After you run a test in the VI Analyzer, you can double-click a failure in the VI Analyzer Results Window to open the VI that failed the test and display the object that caused the failure. Complete the following steps to allow the VI Analyzer to perform this task for custom tests you create.
In the main test VI, use the Traverse for GObjects VI to obtain references to the objects that can fail a test. In the Traverse Target input, select one of the following items from the shortcut menu.
0
FP—Specifies that the Class Name input is a class of object that can exist on the front panel.
1
BD—Specifies that the Class Name input is a class of object that can exist on the block diagram.
2
Other—Specifies to search only the container object wired to the Other Refnum input for the class of object specified by the Class Name input.
Use the References output of the Traverse for GObjects VI in a loop structure to read the UID property of the objects, along with any other properties necessary to perform the test.
Pass the value of the UID property as the Ref Index for any test failures you add to the Results Data array.
Changing the Test Ranking of a Custom Test
The VI Analyzer Test Creator wizard allows you to specify the test ranking when you create a new test. To change the test ranking after you create a test, complete the following steps.
Open the test configuration VI.
Determine whether the configuration page is global VI-based or VI-based. For example, select File and identify the presence of the Global Properties or VI Properties menu item, which indicates that the configuration page is global VI-based or VI-based, respectively.
Show the hidden Test Ranking control.
If the configuration page is global VI-based, display all hidden controls and indicators and select the Test Ranking control in the Show Hidden Controls and Indicators dialog box.
You can run custom tests on other computers with the LabVIEW development system installed. Copy custom test LLBs from the LabVIEW Data\VI Analyzer Tests directory on the development computer to the corresponding location on other computers to allow the VI Analyzer to run the test on the other computers. LabVIEW returns an error if you run a test in an earlier version of LabVIEW than the version in which you created and saved the custom test.