How to Unit Test an Activity Rule |
If your activity requires only a few parameters, you can test it easily using the Run Rule feature. However, if the activity requires extensive setup and is more appropriately tested in context rather than through unit testing, you can trigger the Tracer to start only when the activity is reached.
If you have the AutomatedTesting privilege (through an access role), you can use the features of Automated Unit Testing such as saved test cases and unit test suites for testing your activity. See About Automated Unit Testing and Working with the Test Cases tab for more information.
To test an activity in the context of other activities and rules that produce the needed initial conditions:
For basics of unit testing, see How to unit test a rule with the Run toolbar button.
If your operator ID has the AutomatedTesting privilege through an access role, the Run Against a Saved Test Case choice and the Run Test Case button are available if this rule has saved test cases. To run the rule and see how its behavior compares to that in its previously saved test cases, select a choice from the Run Against a Saved Test Case drop-down list. You can choose to unit test against a specific test case or all test cases.
After making your selection, click Run Test Case. If differences are found between results of running the current state of the rule and the saved test case, they are displayed and you have the options of overwriting the saved test case or choosing to ignore differences for future test runs. (See the Playing back saved test cases section in Working with the Test Cases tab.)
If a white list of pages or properties exists for the test case, differences are not reported for pages and properties that are not on the white list. If a white list exists, then only differences for items on the white list are reported. See Test Case form — Understanding the Results tab.
Testing with the Run button can create one or more clipboard pages, including copies of named pages you identify on this form. The system retains these pages when you close this form; properties on these pages remain available for later tests of this or another rule tested with the Run button.
If the activity returns results to a parameter marked as Out
on the Parameter tab of the activity, you can't see the results using the Clipboard tool. Out parameters reside on the parameter page of the activity, which you can view only with the Tracer tool. To simplify testing, you can modify the activity temporarily to store an Out parameter value in a property that is visible on a clipboard page. Delete the temporary step when you finish testing.
You can use this facility if:
In releases before PRPC 5.2, only activities with the May start? box selected can be unit tested with this facility.