Testing is an important part of business rules and can be done in two main ways:
BRE authors and developers can test rules in the comfort of the Rules Composer by using the Test Policy feature.
Developers can use test rules by using the PolicyTester class.
Both of these methods enable you to test unpublished and undeployed rules, whereas the usual rules execution approach requires that rules be both published and deployed.
To display the Test Policy dialog box, shown in Figure 7-25, right-click a rules policy version in the Policy Explorer and choose Test Policy.
All the fact types required for the rules policy are displayed, and you can provide instances of these fact types to be used to test the policy. XML- and database-based fact types can be provided automatically by the tool.
To browse to an XML file or select a SQL Server database (or so forth), click Add Instance. If you want to use a .NET-based fact, however, you need to provide a custom fact creator. The custom fact creator will create these types, initialize them, and return them so that they can be asserted into the BRE. Of course, you can use a custom fact creator to assert database and XML facts as required. (You could, perhaps, have a fact creator for each type of test, each asserting different data to produce different results.)
Custom fact creators are ...