< Previous | Next >

Task 5: Debugging

In this task, you debug the ruleset, by using the test data from the Excel scenario file that you created in the previous task.

Before deploying the rules to the execution environment and integrating your work into the Miniloan application, you want to make sure that there are no defects and that the rules execute as expected. In Rule Designer, you can execute rules in a sandbox for testing and debugging purposes.

Time This task should take you about 15 minutes to complete.

Step 1: Inserting a breakpoint

You can use an Excel scenario file to debug the execution of the rules. Debugging in Rule Designer allows you to step into both rule code and Java™ code. You insert breakpoints into rules to stop the execution at the location where the breakpoint is set.

To set a breakpoint:

  1. Make sure that the Console view is opened.
    Tip: To open the Console view, on the Window menu, click Show View > Other. In the Show View dialog, select General > Console and then click OK.
  2. In the Rule Explorer, double-click the rules/miniloan ruleflow to display it in the Ruleflow Editor.
  3. Select and right-click the eligibility task in the ruleflow diagram, and click Toggle Breakpoint.

    A breakpoint marker is displayed next to the eligibility task.

    Ruleflow diagram with a breakpoint marker

Step 2: Debugging rule execution

Now that you have inserted a breakpoint, you can start debugging the execution.

To debug the execution:

  1. Start the debugger:
    1. Click Run > Debug Configurations.
    2. In the side pane of the Debug Configurations dialog, select DVS Excel File > Miniloan Test.

      This is the launch configuration that you created in the previous task. You reuse it to debug rule execution.

    3. Click Debug.

      A dialog opens asking you if you want to change to the Debug perspective. Click Yes. The Debug perspective opens. The debugging commands are available from the Debug view, or 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 Step Into button Step Into. Debugging stops at the first action of the minimum income rule.
    2. In the Variables view, expand the loan object. The value of the approved attribute is true.
      Expending the loan object in the Variables view
    3. Click Step Over button Step Over to go to the next action statement in the minimum income rule. This action invokes a method that rejects the loan.
    4. Click Step Into button Step Into. You can now see the Java code of the reject method invoked from the rule. This method is defined in the Java XOM project.
    5. Click Step Return button Step Return to return to the rule. In the Variables view, the approved attribute of the loan object is now false, which means that the loan is rejected.
      Variables view: attribute approved set to false
  3. Click Resume button Resume to complete the execution of Scenario 1.

    The execution of Scenario 2 starts and is stopped at the beginning of the eligibility task.

  4. Click Resume button Resume to complete the execution of Scenario 2.

    When execution terminates, the Console view shows the message:

    --- Output for scenario 'Scenario 1':
    false [Too big Debt-To-Income-ratio]
    --- Output for scenario 'Scenario 2':
    true []
  5. On the Window menu, click Open Perspective > Other > Rule to return to the Rule perspective. Alternatively, the side of the Eclipse toolbar displays the current perspective name as well as buttons to quickly access the other available perspectives.
  6. Close the ruleflow.

You have created a scenario file to test your rules, and you used it for debugging. Now, you can deploy your rules to Rule Execution Server, which is the runtime execution environment that provides a rule engine for your application.

< Previous | Next >