Show TOC

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

 

You create a test case to check the correctness of the rules to determine the eligibility of an applicant for the credit card he/she applied for.

Procedure

Create a Test Case
  1. In the Project Explorer view, expand the creditcard_rules node, the Rules Modeling node and in the context menu of the Test Cases node, choose New XML Test Case.

  2. In the dialog box that appears, enter CreditCardTC in the field and choose OK.

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

    Note Note

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

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

  2. Save the changes.

Creating the XML Document

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

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

  2. In the dialog box that appears, the Choose XSD radio button is selected by default. Choose src/wsdl/CreditCard.xsd{http://www.example.org/CreditCard}.

  3. Choose OK.

  4. In the screen that appears, in the File name: field enter CreditCard.xml.

  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 CreditCard.xml when you expand the src and brmstests nodes. CreditCard.xml 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 src/brmtests/CreditCard checkbox and choose OK.

  3. You should see src/brmsets/CreditCard.xml 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, chooseCreate Data Source (Create Data Source) in the top right corner.

  2. In the dialog box that appears, enter CreditCardDS.csv and choose Finish.

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

  3. Enter data in the format as shown below:

    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 CreditCardDS.csv 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, choose src/brmsets/CreditCard.xml and choose the Add XPath button.

  3. In the dialog box that appears press Ctrl and double-click the following elements:

    • tns:CreditCard/tns:AnnualIncome

    • tns:CreditCard/tns:CreditHistory

    • tns:CreditCard/tns:CardType

    • tns:CreditCard/tns:TotalAssets

    Choose OK.

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

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

    This graphic is explained in the accompanying text.

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

  7. In the Output Mapping section, choose src/brmsets/CreditCard.xml and choose the Add XPath button and in the dialog box that appears, double-click tns:CreditCard/tns:Eligibility and choose OK.

  8. In the Comparator column choose Equals in the drop down menu.

  9. In the Value column , choose Eligibility in the drop down menu.

Running the Test Case
  1. In the Test Case editor, chooseRun 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

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

      • Choose   Window   Preferences  

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

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

    End of the note.