Task 4: Testing and debugging

You run the ruleset by entering input data in a decision operation configuration, and then test and debug your ruleset.

About this task

You use Rule Designer to test and debug your rule project. You create a run configuration to run the decision operation in Rule Designer. Then, you insert a breakpoint that stops the run at a specific point in the ruleflow, and run the decision operation by using a debug configuration.

Step 1: Creating a run configuration

To test whether the ruleset can run, you run the decision operation in Rule Designer.

Procedure

  1. Click Run > Run Configurations.
  2. Right-click Decision Operation and click New.
  3. In the Name field, enter Miniloan Test for the name of the launch configuration.
  4. To set the decision operation, browse to my decision service/my operation.
  5. On the Parameters & Arguments tab, click borrower and Edit Value.
  6. In the Edit Parameter Value wizard, ensure that the Expression value is selected, enter the following text, and then click OK:

    new miniloan.Borrower("Joe", 600, 8000)

  7. Repeat steps 5 and 6 to set loan to the following text:

    new miniloan.Loan(50000, 240, 0.05)

  8. Click Apply, and then click Run to run the Miniloan test configuration.

Results

In the Console view, you see the results:

Image shows message.
Tip:

To open the Console view, on the Window menu, click Show View > Other > General > Console, and then click OK.

Step 2: Inserting a breakpoint

You set a breakpoint in Rule Designer to debug rules.

Procedure

  1. In the Rule Explorer, double-click the miniloan ruleflow to display it in the Ruleflow Editor.
  2. Select and right-click the eligibility task in the ruleflow diagram, and then click Toggle Breakpoint.

    A breakpoint marker is added to the eligibility task:

    Image shows the breakpoint marker in the eligibility node.
  3. In the Rule Explorer, open eligibility and double-click the minimum income rule to open it in the Intellirule editor.
  4. Right-click the fourth line of the rule in the margin, and select Toggle Breakpoint to add a breakpoint to the first action in the rule:
    Image shows the toggle breakpoint.

Step 3: Running the debugger

With the breakpoint in place, you can debug the execution.

Procedure

  1. Start the debugger:
    1. Click Run > Debug Configurations.
    2. Select Decision Operation > Miniloan Test.
    3. Click Debug.
    4. When a dialog is displayed, click Yes to open the Debug perspective.
      The debugging commands are available from the Debug view and from the Run menu.

      Debugging stops at the beginning of the eligibility task, where you inserted the breakpoint.

  2. Step through the rule code:
    1. Click Resume"". Debugging stops at the first action of the minimum income rule at the second breakpoint that you inserted.
    2. In the Variables view, expand the loan object. The value of the approved attribute is true:
      Image shows the expended loan object in the Variables view.
  3. Click Resume "" to complete the run.

    When the run ends, the Console view shows the following message:

    Image shows message.
  4. Return to the Rule perspective, and close the ruleflow.

What to do next

You created a decision operation configuration to test your rules, and you used it to debug your rules. You can now deploy your rules to Rule Execution Server.