Open Your Business Rules!
Rules-based
Operational Decision Services
OpenRules Classic: Rule Testing
Rule Testing is one of the most important phase of the BR Management cycle. OpenRules allows business people (not programmers) to be in control of BR development, testing, and maintenance. This direct control can lead to dramatic improvements in the quality of the business rule repository.
OpenRules Testing Facilities
OpenRules provides the ability to define new data/object types and create objects of these types directly in Excel spreadsheets. To organize a rules testing environment, the rule designer usually does the following:
- specifies his/her own data types as Excel "Datatype" tables
- creates test instances of objects of these types using Excel "Data" tables
- creates an Excel Method table that calls the proper appropriate Rules tables and passes to them the instances of test data.
Based on the complexity of the rules, a user may create a more sophisticated test environment that utilizes user-defined test cases along with expected results. Different use cases may be placed in separate Excel files using similar Data tables but different test data instances. The expected results can be placed in separate data tables. In order to compare the results of the different use cases the customer has to write a problem specific method which is also placed in an Excel table.
The use of OpenRules Forms allows a developer to create a Web-based interactive testing environment. When test data is entered online, the appropriate rules will be invoked with a push-button, and the results of rules processing are presented in a Web browser.
This approach allows business analysts to define business terms and facts in Excel without worrying about their actual implementation in Java, C#, or XML. These terms and facts are used to represent and test business rules in a pre-integrated mode. Automated rules can be executed and tested even before integrating rules with an existing application by using Excel-based test data.
OpenRules Test Data Modeling
OpenRules allows a non-technical user to represent different data types directly in Excel and to define objects of these types to be used as test data. Actually, it provides an ability to create Intelligent Business Glossaries that define problem specific business terms and facts. At the same time, a business glossary can include data types specified outside Excel, for example in Java classes or in XML files. Here is an example of a simple data type "PersonalInfo":
Now we can create several objects of this type "PersonalInfo" using the following data table:
We can place references to these objects inside rules or forms as in the following Java snippets:
out(personalInformation["He"].lastName);
if (personalInformation["She"].state.equals("NJ")) ..You may use the defined datatype to define a more complex aggregate datatype as in the following example:
You may even create an object of the new composite type "TaxReturn" using references to the the objects "He" and "She" as in the following example:
Now, if we have tax calculation rules specified in the rules table
"Rules void taxCalculationRules(TaxReturn return)"
we can test these rules using test data from the first [0] row of the array "taxReturns":
taxCalculationRules(taxReturn[0]);
These examples gives you an intuitive understanding of OpenRules Datatype and Data tables. You may get further details from the User's Manual.
Examples
The are many examples of rule projects with Excel-based test data in the standard OpenRules distribution. To see a practical example of how this methodology is implemented, please click here.