Back Forward How to unit test a Declare Expression rule

About Declare Expression rules

C-1493 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. C-2597 ADD PAGE button RUN button

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. REMOVED NORIR 5/23/06 You cannot use this facility to test a Declare Expression rule that iterates through a Page List or Page Group property.B-10801 GAGNP 11/9/04

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 button (Run) or the equivalent keyboard shortcut CTRL + R 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 model rule 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, for example, Due By.

2. Enter a value for the an independent property and click  Update  .

3. Repeat steps 1 and 2 to test with each independent property. The system computes and displays values for the dependent properties (Deadline, 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: C-2597

  1. Select the Add new page checkbox.
  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 model inputs

As an alternative to typing property values, you can create a model rule that contains 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 present, select Create or Reset this Test Page and specify a model.

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 model rule), executes the Declare Expression rule, and displays the result.

3. Repeat these steps with other model rules, 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 model rule or rules to enter tests for such cases. GAGNP 11/9/04v

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. NORIR BUG-4501 SR-9959

Definitions dependency network, special property

Up About Declare Expression rules