Table of Contents

Unit testing a Service Java rule


Only available versions of this content are shown in the dropdown

Use the unit testing feature to verify that the operations of a Service Java rule function correctly before you add the external client to your testing process.

Service Java rules are no longer being actively developed, and are being considered for deprecation in upcoming releases. Using Service Java rules does not follow Pega development best practices. Consider other implementation options instead.

Unit testing provides only partial evidence of a correct implementation. For more comprehensive information on testing services, see the Pega Community article Testing Services and Connectors.

Before you begin, see How to provide test data when testing service rules.

To run a unit test, complete the following steps:

  1. Save the rule form.
  2. Start the Tracer by clicking Actions Trace . For more information, see Tracing services.
  3. Click Actions Run .
  4. Complete the form as described in the following table, and then click Execute.
Field Description
Requestor Context Select a radio button to define the requestor session is to be used in the test:
  • Use current requestor context — Use your current requestor session (including your RuleSet list, privileges, and current clipboard).
  • Initialize service requestor context — Create a new requestor session based on the APP requestor type and, if the service package requires authentication, another Operator ID instance.

Authentication User ID If you selected Initialize service requestor context , and the service package instance for the service requires authentication, enter the Operator ID to be used to test the service.
Authentication Password If you selected Initialize service requestor context , and the service package instance for the service requires authentication, enter a password for the Operator ID.
Enter Request Data Select a radio button to define the source of request data values for this test:
  • Specify individual request values — This option appears only if the Java method parameters are scalar values, such as strings, numbers, or booleans.
  • Invoke Initialization activity — A test activity creates values for the Java method values.

Method Parameter Values If you selected Specify individual request values for the previous field, enter in the Value field a literal constant value for each Java method parameter declared on the Parameters tab. Enter a value that corresponds to the Java data type listed.
Activity If you selected Invoke Initialization activity, enter here the Activity Name key part of an activity that creates Java method parameters. The system assumes the Applies To class of the activity matches the Primary Page Class value on the Service tab. If the activity applies to a different class, enter the class name, a period, and the activity name.

Related Content

Did you find this content helpful?

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.