Back Forward Activity form
How to unit test an activity

About Activity rules

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:

  1. Open the activity in the workspace.
  2. Select Run > Trace Open Rule. The Tracer tool starts.
  3. Optionally, click Optionsto 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.
  4. 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.

  1. Optional. Using the Clipboard tool or other means, set up clipboard pages, property values, and other initial conditions.
  2. Next, start the Tracer tool if you want to monitor activity execution. Set Tracer options.
  3. Click the Run toolbar button (Run) or the equivalent keyboard shortcut CTRL + R. A pop-up form appears.
  4. If the text requires a test page, select the Create a Test Page radio button. Click  Run Rule  .
  5. 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.
  6. 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.)
  7. 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.
  8. Click  Execute   to start the activity in your requestor session.
  9. 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.
  10. If the execution causes errors, an error form appears.
  11. 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.

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.

TipIf 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:

(OldIn releases before Process Commander 5.2, only activities with the May start? box selected can be unit tested with this facility.)

zzz About Activity rules