How to unit test a data transform

About Model rules

The Run Rule feature enables you to test a data transform individually, before testing it in the context of the application you are developing.

Preparation

  1. Examine the rule. Review the Applies To key part, the Definition, Parameters, and Pages & Classes tabs of the rule to identify the classes of the pages it uses and the pages and properties involved in the data transform.
  2. The Run Rule feature can create or copy a page to use as the test page, as appropriate for the rule you are testing. The page class of the test page is the Applies To class of the rule. If necessary, you can create a data transform (separate from the one you are testing) to set initial values for the test page.
  3. If the rule requires input from several pages, determine how to mimic the processing that creates them so the clipboard has the initial context (pages and properties) needed for the data transform. For example, if the Applies To class involves a work type, you can open a work item of the corresponding class to create and load relevant clipboard pages.
  4. For more comprehensive testing, create one or more additional data transforms that load various sets of input values into the clipboard.

Test approach

For basics of unit testing, see Unit testing a rule with the Run toolbar button.

  1. Save the Data Transform form.
  2. Click the Run toolbar button (Run) or the equivalent keyboard shortcut CTRL + R to open the Run Rule window. The Run Rule window opens.
  3. In the Test Page section, specify whether to pre-populate the main test page with values from another data transform before invoking the to-be-tested rule:
  4. If the rule being tested is circumstance-qualified, select Set circumstance properties to run exact version of rule. Otherwise, the base version or a different circumstance-qualified version might be invoked other than the rule form from which you opened the Run Rule window.
  5. If Empty Test Page is selected, click Reset to ensure the test page on the clipboard is appropriately reset. If Create or reset Test Page is selected, the displayed button has one of the following labels: Click the displayed button to ensure the test page is pre-populated according to the data transform specified in step 3.
  6. In the lower section of the Run Rule window, enter any test data (if any) needed by the tested rule, and click Execute to run the test.
Repeat as desired, selecting different data transforms to pre-populate the test page, or providing other input values.

Up About Data Transforms