Unit testing a declare expression
You can test a declare expression individually, before testing it in the context of the application that you are developing. Additionally, you can convert the test run to a Pega unit test case.
Unit testing a declare expression involves specifying a test page for the rule to use, providing sample data as the input, running the rule, and examining the results.
You can unit test Declare Expression rules for which all properties referenced in the expression 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.
The following considerations apply when unit testing a declare expression:
- Using data transforms – You can unit test a declare expression by using a data transform to set property values or by manually entering values if all properties in the computation are Single Value properties and they belong to a single Applies To class.
- Testing expressions involving aggregate properties – If the expressions involve aggregate properties, use this facility only with Page Group or Page List properties with a small number of elements.
- Avoiding infinite loops – To avoid infinite loops caused by recursion, this facility uses an internal limit of 999 computations, counting both iterations over List and Group properties and expression evaluations. If this limit is reached during a test execution, the evaluation ends with an error message.
-
Testing expressions involving special properties – Your expression can involve special properties (standard properties with names starting with px or your properties marked as special), Value List, or Value Group properties. You cannot use manual inputs to change the value of a special property. Instead, you can make changes to special properties by using a data transform.