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.
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.
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
If the test case editor does not appear, expand the Test Cases node and double-click the CreditCardTC node.
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.
Save the changes.
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.
In the Test Case editor, choose (Create XML) in the top right corner.
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}.
Choose OK.
In the screen that appears, in the File name: field enter CreditCard.xml.
Choose Next. In the screen that appears, accept default selections or change the selections according to your choice.
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
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.
In the Test Case editor, in the XML Documents for Test Input section, choose the Add XML button
In the dialog box that appears, select the src/brmtests/CreditCard checkbox and choose OK.
You should see src/brmsets/CreditCard.xml listed in the XML Documents for Test Input table.
Save the changes
The Data Source is a CSV file that contains the input data and expected output data for testing the correctness of your rules.
In the Test Case editor, choose (Create Data Source) in the top right corner.
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.
Enter data in the format as shown below:
Save the changes.
In the Test Case editor, in the Test Data section, choose the Set Data Source button.
In the dialog box that appears, choose CreditCardDS.csv in the drop down menu and choose OK.
Note
Choose the Open button to edit the data source
Before you run the test case, you can choose the Refresh button.
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.
In the Test Case editor, choose the Detailed Configuration tab.
In the tab page that appears, in the Input Mapping section, choose src/brmsets/CreditCard.xml and choose the Add XPath button.
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.
In the Input Mapping section, in the table, the Mapping Element column displays the XML elements you added.
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.
Repeat the step until you map all the XPaths with the header names.
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.
In the Comparator column choose Equals in the drop down menu.
In the Value column , choose Eligibility in the drop down menu.
In the Test Case editor, choose (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
If you do not see the Rule Testing Console window:
Choose
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
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