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 National Instruments Web site 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.
Failure Highlighting—After running tests, VI Analyzer can highlight VIs and VI objects that cause failures if you configure that ability in a global VI in the LLB.
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.
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.
Add code to bundle a failure message string and the numeric index of the object that failed into a cluster wired to the Results Data array. If the test checks properties of a front panel or block diagram rather than a VI object, bundle an index of 0 with a failure message.
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 test RD.vi, click the Traverse Target control and select one of the following items from the shortcut menu.
0
FP—Specifies that front panel objects can fail the test.
1
BD—Specifies that block diagram objects can fail the test.
Enter the class name of an object that can cause the test to fail in the Class string control. For example, if the test checks enumerated type controls, enter Enum in the string control.
Repeat steps 1 and 2 in subsequent elements of the Reconstruct Array for additional classes that can cause failures.
Right-click the array shell and select Data Operations»Make Current Value Default from the shortcut menu to save these settings.
Other Ways to Highlight Failures
When the value of Traverse Target is Other, you can specify the following strings in the Class string control to configure the VI Analyzer to highlight parts of VIs and groups of specific objects:
CONPANECTLS—Allows all controls and indicators assigned to connector panes to be highlighted.
Diagram—Allows block diagrams to be highlighted.
ERRORIO—Allows the error in controls and error out indicators assigned to connector panes to be highlighted.
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.