Comparing unit testing with in-context
testing
If your activity requires only a few parameters, you can
test it easily using the Run toolbar button, as described
below. 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.
In-context testing
To test an activity in the context of other activities and
rules that produce the needed initial conditions:
- Open the activity in the workspace.
- Select Run > Trace Open Rule. The Tracer
tool starts.
- Optionally, click to open the Trace Options panel, and
deselect the RuleSet containing the activity. This
eliminates Tracer output from other rules in the RuleSet.
Exit from the Tracer.
- Begin other processing that eventually calls the activity
in your own requestor session. Tracer output begins when the
activity starts.
Unit testing
For basics of unit testing, see How to unit test a rule
with the Run toolbar button.
- Optional. Using the Clipboard tool or other means, set up
clipboard pages, property values, and other initial
conditions.
- Next, start the Tracer tool if you want to monitor
activity execution. Set Tracer options.
- Click the Run toolbar button () or the equivalent keyboard shortcut
CTRL
+ R
. A pop-up form
appears.
- If the text requires a test page, select the
Create a Test Page radio button. Click
Run
Rule .
- Complete the Test Page area. You can
identify an existing clipboard page of an appropriate class
as a source of values, or create a new page of that class and
initialize values on that page using a model.
- If the activity uses parameters, the system presents an
input form for parameters. Enter constants for input
parameters as prompted. (Some input parameters may be
optional.)
- Optionally, you can save parameter values and a link to
this activity as a personal shortcut. A shortcut is helpful
if you need to repeat this test often. To create a shortcut,
click Add
to Shortcut and
enter a name. See About shortcuts
and the Organize Shortcut tool.
- Click Execute
to start the activity in your requestor session.
- As the activity runs, it may update your clipboard, open
and alter instances, display HTML forms, and so on. It uses
your current RuleSet list and access roles.
- If the execution causes errors, an error form
appears.
- Use the Clipboard tool and the Tracer tool to uncover
errors and view processing details.
Saving activity tests in a Test Case rule
If you have the AutoTest capability enabled, select Run Against a Saved Test
Case. Then choose an individual test case from the
drop-down list.
- If Automated
Testing is enabled, you can click the Save as
Test Case button to create a test
case rule that holds the test data and the results.
For information about running test cases, see the
Pega Developer Network document PRKB-25597 How to unit test activities with the Automated Testing feature.
Clipboard contents
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, 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 the Out parameter value in a
property that is visible on a clipboard page. Delete the
temporary step when you finish testing.
Notes
You can use this facility if:
- The May start? check box is selected on
the Security tab, or
- Your access role allows you to update rules that have the
Applies To class of this activity.
(In releases before Process
Commander 5.2, only activities with the May
start? box selected can be unit tested with this
facility.)
About Activity rules