Siebel Business Rules Administration Guide > Integrating Rules with Siebel Runtime Events > Scenario for Using Rules to Validate Data at Runtime >

Testing the Rule Modules in HaleyAuthority


You can use the test harness in HaleyAuthority to test your rules in a simulation environment before deploying the rule modules.

For instruction on using the test harness, see Using the HaleyAuthority Test Harness.

Testing your rules in HaleyAuthority includes the following tasks:

  • Create a test case.
  • Create example instances of the entities that the rule module processes.
  • Run the test case.
  • Examine the test results.
  • Modify the data and rerun the test case. (optional)

To create a test case

  1. In HaleyAuthority, choose View > Tabs > Tests & Cases.

    The Tests & Cases window displays.

  2. Right click the Test Cases folder and choose Add a test case.
  3. In the Edit Test Case dialog box, enter a name for the test case in the Description field; for example, Service Request Validation - PreWriteRecord test, then click OK.

Create the instances that serve as simulated data on which the rules act. For this example, first create a simple service request with no other associated data.

To create an example instance for the test case

  1. Choose View > Tabs > Concepts.

    The Concepts window displays.

  2. Locate and right click the service request entity, then choose Add > an instance or example.
  3. In the instance dialog box, make the following entries, then click OK:
    • A label for the instance; for example, example_service_request_1.
    • Click the This is an example for testing purposes only checkbox.

      The Instances folder under service request now contains the example_service_request_1 instance.

  4. Right click the example_service_request_1 instance and choose Test cases, click the Service Request Validation - PreWriteRecord test checkbox, then click OK.

Note that the example_service_request_1 instance has no service request items or field values associated with it.

To run the test case

  1. Choose View > Tabs > Tests & Cases.

    The Tests & Cases window displays.

  2. Locate and right click the Service Request Validation - PreWriteRecord test test case and choose Test case.
  3. In the HaleyAuthority Enterprise dialog box, click Yes to deploy (or redeploy) your logic.
  4. In the Deploy Configuration dialog box, make the following entries, then click OK.
    • Confirm the following checkboxes are checked: Deployment, model, measures, unauthoredRules, and unauthoredDiagnostics.
    • Check the checkbox for Service Request Validation - PreWriteRecord, and leave the checkboxes for all other modules unchecked.
    • Enter or browse to choose a directory for the deployed module; for example, D:\temp.

      NOTE:  This directory has no persisting value, and does not affect the eventual runtime database to which the module is deployed.

      The test case runs.

The test case provides the following output:

  • The Output window provides a log of the statements that were executed. These include unconditional action statements, conditional statements for which the if clause is true, and applicability statements that are true.

    NOTE:  Siebel-specific functions (imported on your initial import with Object Importer) result in a Loaded undefined function 'function name' line. However, the output indicates that the simulated test executes those functions.

  • An entry of the form Service Request Validation - PreWriteRecord test on <date and time> is added to the Test Results folder under Service Request Validation - PreWriteRecord test. Expand this folder to see the statements that were executed:

    1 if a service request does not have a contact last name then invalidate the service request with "A service request must have a contact."

    1 if a service request does not have an account then invalidate the service request with "A service request must have an account."

    1 if a service request does not have a description then invalidate the service request with "A service request must have a description."

    1 if a service request does not have an area then raise an error as "Enter the area for the service request."

    The condition for the only other statement in the module, that a service request has an activity plan without a name, is not satisfied by the example instance. The instance does not have an activity plan.

To test other conditions of your rule module, modify your example instances and rerun your test case. Alternatively you can create separate example instances, separate test cases, or both. For this example, modify example_service_request_1 to have an activity plan and some field values to test. You must set properties for your service request instances and for an activity plan instance.

To create example instances with properties

  1. Create an example instance of activity plan by following the instructions in To create an example instance for the test case. Name the instance, for example, example_activity_plan, and associate it with the Service Request Validation - PreWriteRecord test test case.
  2. Right click on example_service_request_1 and choose Properties, then click the Facts tab.
  3. Click the New icon and select example_service_request_1 has an account. In the Account field, enter ABC Company, then click OK.
  4. Similarly, add the following properties to example_service_request_1. In some cases, you will choose values from a pick list.
Property
Value

has an activity plan

example_activity_plan

has an contact last name

Lee

Rerun Service Request Validation - PreWriteRecord test simulation. The test results correctly list the following statements as being executed:

1 if a service request does not have a description then invalidate the service request with "A service request must have a description."

1 if a service request does not have an area then raise an error as "Enter the area for the service request."

1 if a service request has an activity plan that does not have a name then raise an error as "This service request has an activity plan that does not have a name."

Vary your instance properties and rerun the test case to test other aspects of your rule module.

Create example instances and test cases similarly to test the Service Request Validation - WriteRecord and Service Request Activity - PreWriteRecord modules.

Siebel Business Rules Administration Guide Copyright © 2007, Oracle. All rights reserved.