Show TOC

Procedure documentationCreating and Running a Test Case Locate this document in the navigation structure

 

You can test the correctness and effectiveness of the rules before you deploy and execute them by creating test cases.

Example Example

If you want to check the effectiveness of the credit card eligibility rules you have created, you can create a lot of test cases capturing different scenarios and put all the test cases in one test case folder.

End of the example.

In a test case, you use a CSV file to capture multiple sets of simulated data for testing.

Procedure

Creating a Test Case Folder

Test Case folders help you categorize test cases.

Example Example

If you want to check the correctness of the credit card eligibility rules you have created, you can create a lot of test cases capturing different scenarios and put all the test cases in one test case folder.

End of the example.
  1. Locate the Test Cases node (Where is the Test Cases node?) and in the context menu of the Test Cases node, choose New Folder.

  2. In the dialog box that appears, enter the name of the folder and choose OK.

When you expand the Test Cases node, you should see the test case folder.

Creating a Test Case
  1. Locate the Test Cases node (Where is the Test Cases node?) and in the context menu of the Test Cases node or test case folder node, choose New XML Test Case.

  2. In the dialog box that appears, enter the name of the test case and Choose OK.

    You should see the test case when you expand the Test Cases node or test case folder node. The test case editor appears.

    Note Note

    If the test case editor does not appear, expand the Test Cases node and double-click a test case.

    End of the note.
Setting the Target Ruleset
  1. In the Test Case editor, choose the Setup tab, in the tab page that appears, locate Target Ruleset: and in the drop down menu choose a ruleset.

  2. Save the changes.

Note Note

If you run a test case during different time duration, you might get different results. If you have set effectivity for your rules, you need to specify the date and time when the rules will be effective before you run the test case. This will help you get the desired result irrespective of the time when the test case gets executed.

  • In the Test Case editor, locate As on and choose and select the date and time of rule effectivity

End of the note.
Creating the XML Document

You create an XML document based on the XML schema you used to write your rules. The XML document contains the data for the test case.

x`

  1. In the Test Case editor, choose Create XML (Create XML) in the top right corner.

  2. In the dialog box that appears, the Choose XSD radio button is selected by default. Select the XML schema of your choice.

  3. Choose OK.

  4. In the screen that appears, in the File name: field enter a name for the XML document.

  5. Choose Next. In the screen that appears, accept default selections or change the selections according to your choice.

  6. Choose Finish.

    In the Project Explorer view, you should see the XML document when you expand the src and brmstests nodes. The XML document opens in the Design view of the editor window.

    Note Note

    You do not have to enter any data in the XML document when you are using a data source (CSV file) to capture the test data.

    End of the note.
Adding the XML Document to the Test Case
  1. In the Test Case editor, in the XML Documents for Test Input section, choose the Add XML button

  2. In the dialog box that appears, select the checkbox referring to the XML document you created and choose OK.

  3. The XML document gets listed in the XML Documents for Test Input table.

  4. Save the changes

Creating the Data Source

The data source is a CSV file that contains the input data and expected output data for testing the correctness of your rules.

  1. In the test case editor, choose Create Data Source (Create Data Source ) in the top right corner.

  2. In the dialog box that appears, enter a name for the data source and choose Finish.

    The data source opens in the editor window. You should see a blank window.

  3. Enter data in the editor window.

    Note Note

    • Make sure you list the headers in the first row and then enter respective values in the rows below the header row

    • The values must be separated by a comma (,)

    • The values are case sensitive. Make sure you enter values in the same format as specified in the If-Then rules and Decision Tables

      Example Example

      Here is an example of an if-then rule:

      If

      Credit history of the applicant = GOOD

      Credit score > 50

      Card applied for = Gold

      Then

      Set message = Is eligible for Gold card

      For the example above, when you enter values in the data source under respective headers, you must enter values in the format such as “GOOD”, “Gold”. Otherwise the test case will fail.

      End of the example.
    End of the note.

    Here is an example of a data source (CSV file):

    This graphic is explained in the accompanying text.

  4. Save the changes.

Adding the Data Source as Test Data
  1. In the test case editor, in the Test Data section, choose the Set Data Source button.

  2. In the dialog box that appears, choose a data source file in the drop down menu and choose OK.

    Note Note

    • Choose the Open button to edit the data source

    • Before you run the test case, you can choose the Refresh button

    End of the note.
Mapping XPath to Constant Values or Header Names in the Data Source

When you run the test case, the values from the data source must be taken as input data and expected output data. So you need to map the XML elements you have used in your rules with the header names in the data source. When you map the output data you compare the expected output with the actual output using a comparator. This indicates if the test case has failed or passed.

  1. In the test case editor, choose the Detailed Configuration tab.

  2. In the tab page that appears, in the Input Mapping section, select the root element and choose the Add XPath button.

  3. In the dialog box that appears press Ctrl and choose all the elements that you want to set as input data for the test case and press the Select Actions button. Choose OK.

  4. Choose the Add Definition button to add a definition as input data for the test case.

  5. In the dialog box that appears, choose Project Resources or a ruleset name in the drop down menu. All definitions in the ruleset or Project Resources appear.

  6. Select a definition checkbox and choose OK.

  7. In the Input Mapping section, in the table, the Mapping Element column displays the definitions and XML elements you added.

  8. Choose the corresponding cell to each element or definition in the Mapping Element column, and in the drop down menu you should see all the header names as specified in the data source. Make sure the header name you choose is the same as the XML element or definition.

  9. Repeat the step until you map all the XPaths with the header names.

    Note Note

    If you want to enter a constant value, choose the cell and enter the value

    End of the note.
  10. In the Output Mapping section, add the XML elements or definitions you want to set as output data for test case

    In the table, the Mapping Element column displays the definitions and XML elements you added.

  11. In the Comparator column choose a comparator in the drop down menu.

    Note Note

    You can use one of the following comparators:

    • Equals

    • Not Equals

    • Less Than

    • Less Than Equals

    • Greater Than

    • Greater Than Equals

    • Like

    • Not Like

    End of the note.
  12. In the Value column , enter a constant or choose a header in the drop down menu.

  13. If the output of the test case is a numerical value, you can use the cell in the Formatter column to specify the format of the numerical value such as #.#. #.##, ###,###.###, 000000.000,$###,###.### and so on.

Note Note

In the Input Mapping and Output Mapping sections, you can choose Edit XPath in the context menu of any elements in the Mapping Element column. In the dialog box that appears, you can edit the XPath and choose an alternative return type in the drop down menu

End of the note.
Setting Custom Properties
  1. In the test case editor, in the Custom Properties section, you should see two options:

    • Use first data row of data source as default value: This option indicates that when no value is available for a column in a data row (for data source), the first row value for that column is used if set to true, otherwise value is taken as "".

    • Maximum number of failed data rows with trace details: This options allows you limit the number of trace details (for failed test data) to be displayed in test report .

Running the Test Case
  1. In the test case editor, choose Run Test Case (Run Test Case ) in the top right corner.

    In the Rule Testing Console window, you should see the location of the test case report. Access the report in the specified location.

    Note Note

    • If you do not see the Rule Testing Console window:

      • Choose   Window   Show View   Other  

      • In the dialog box that appears, expand the Rules node and choose Rule Testing Console and choose OK

      • Choose   Window   Preferences  

      • In the dialog box that appears, on the left hand side, expand the Rules Composer node and choose Rule Testing

      • If you want to change the location of the test report:

        Locate Report Location: and choose the Browse button to specify the location of your choice

      • You can also set properties for a test case

    End of the note.