Testing rulesets in Rule Designer

To validate rulesets against scenarios, you set up and run a testing configuration.

About this task

You can generate a template of the scenarios file where you enter the values that you want to test. Then, you set up the testing configuration by specifying a decision operation and the Excel file that contains the scenarios.

For a demonstration on testing rulesets Rule Designer, watch the following video:

Video shows how to test a ruleset in Rule Designer.

Procedure

  1. If you don't already have one, create a scenario file. To generate a template scenario file, see Generating an Excel scenario file.
  2. Optional: You can add breakpoints in various artifacts of the project to pause the execution of the test in strategic places for debugging purposes. To learn more about breakpoints, see Breakpoints.
  3. Right-click the project that you want to test and select Debug as > Debug configurations....
  4. In the list of configurations, right-click Testing decision operation and click New.
  5. Give this configuration a name and specify the Excel file that contains the scenarios and the decision operation to use.
  6. Click Debug.

Results

The results of the execution display in the Console view: you see whether each scenario was successful, the time it took to run it, and the number of run rules and tasks.

The results for the scenarios use the following statuses:

  • Successful: A test is successful when the expected results match the actual results.
  • Unsuccessful: A test is unsuccessful when the expected results are different from the actual results.
  • Error: An error is reported when the test cannot run the scenarios, for example, when an entry in the scenario file is not correctly formatted.

If there are breakpoints in the rules of the project, the execution stops when it encounters one and the Debug view opens. You can then see which breakpoints stopped the execution and you can continue the resume the execution until the next breakpoint.

Example

Here is an example of the results of a test with three scenarios:
********************************************************
Scenario Number 0 : 'Rejected loan' = Success  
Time = 16, Nb Executed Rules = 1, Nb Executed Tasks = 3
********************************************************
Scenario Number 1 : 'Big amount loan' = Failure  
Expected result 'the loan is approved equals ': Failed
Time = 0, Nb Executed Rules = 1, Nb Executed Tasks = 2
********************************************************
Scenario Number 2 : 'Approved loan' = Success  
Time = 0, Nb Executed Rules = 0, Nb Executed Tasks = 3
********************************************************
Nb Executed 3
Nb Failures 1
Nb Errors 0
End running the JVM for testing

The Rejected loan scenario and the Approved loan scenario were successful, meaning that the expected values defined in the scenarios match the actual results of the tests. The Big amount loan scenario failed because the rule that approves the loan did not produce the expected result.