Show TOC

Rules TestingLocate this document in the navigation structure

Use

The rules testing feature allows you to test the correctness of the rules based on XML schema before you deploy and execute the rules. The input to the testing engine are a finite set of XML documents (static input) and user selected XPaths that are mapped to test data table headers (dynamic input). At the time of test execution, the input static XML documents are loaded, and then data table values mapped to input XPaths are used to update the XML document objects, for each test data row. The updated XML document objects are used for rule engine invocation.

A rule test case is composed of:

  • Test target : Since the executable unit of any business rules project is a ruleset, the test target is a ruleset which contain the rules that need to be tested given a set of input data and expected output data.

  • Test data : Test data is the input and expected output data required for testing rules. The input data can be historical data or simulated data which is captured in a CSV file. With respect to simulated data, the first row of CSV file has header names and the data can be entered in the row under each header name. Each row of data represents a unique test/validation aspect. The test target is invoked for each test data row.

  • Test mapping: Test mapping involves mapping input and output XPaths to values. To enable participation of non-technical personnel in business rules validation, the input data (flat tabular model containing simple business terms as headers, and primitives as values) has been separated from the business object model. You need to configure the attributes in XSD types, and primitive fields in Java types to map to test data table headers.The values can be constant values or they can come from the dynamic data source ( the CSV file). You can model the output XPath mapping to data table values. The XML documents returned from the rule engine are used to evaluate the output XPath values and then compared against the corresponding expected values specified in test data table.