Back Forward How to unit test a Declare Expression rule

About Declare Expression rules

You can test a Declare Expression rule as a unit, before or after the rule is integrated into the rest of the application under development.

NoteThis facility is available only for Declare Expression rules for which all properties used by the computation belong to a single Applies To class, or to one class plus superclasses of that class. For example, you cannot use this facility to test a computation that involves both a Data-Account property and an Assign-Workbasket property.

Test approach

For basics of unit testing, see How to unit test a rule with the Run toolbar button.

1. Save the rule form.

2. Click the Run toolbar action to open a guided test window.

3. The window displays the dependency network for the target property. After you supply values for the independent properties, the system evaluates the Declare Expression rule evaluates and displays the results. You can enter values for other properties in the computation, or apply a data transform that supplies such values.

Testing with manual inputs

Use this approach if all properties in the computation are Single Value properties and belong to one Applies To class.

1. Click an independent property on the dependency network. In the example illustration, Department is selected.

2. Specify a value for the independent property (in the Property section in the lower right corner of the window) and click  Update  . In the example illustration, Engineering is selected as the value of Department.

3. Repeat steps 1 and 2 to test with each independent property. The system computes and displays values for the dependent properties (Remaining Budget, in this example).

If the test requires creating an element as part of an embedded Page List or Page Group property, the system displays a prompt to create a new page. To create the additional element:

  1. Select the Add new page check box.
  2. For a Page Group, enter an identifier as subscript value (For a Page List, the system appends the new page after existing pages.)
  3. Select the class of the page.
  4. Click  Update  .

Similarly, you can add an element to a Value List or Value Group property.

Testing with inputs from a data transform

As an alternative to typing property values, you can create a data transform that sets the values defining a test case.

1. The system presents a list of clipboard pages with classes that may match the Applies To key part. Select the clipboard page that contains values for the rule. If no page of the appropriate type is already present on the clipboard, select Create or Reset this Test Page and specify a data transform to apply to the page.

2. Click  Create Page and Run Rule  . The system makes a temporary copy of the page you selected (or creates a new temporary page and applies the data transform), executes the Declare Expression rule, and displays the result.

3. Repeat these steps with other data transforms, or alter the clipboard contents and repeat the test.

Computations involving special properties

Your computation can involve special properties (standard properties with names starting with px, or your properties marked as special), Value List, or Value Group properties.

You can't use manual input to change the value of a special property; instead, define a data transform or rules to enter tests for such cases.

Notes

If the expressions tested involve aggregate properties, use this facility only with Group or List properties with a small number of elements. To avoid runaway processing caused by recursion or a possible infinite loop, this facility uses an internal limit of 999 computations, counting both iterations over List and Group properties and expression evaluations. If during a test execution this limit is reached, processing ends with an error message.

Definitions dependency network, special property

Up About Declare Expression rules