7.4. Testing

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.

7.4.1. Test Policy

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.

Figure 7.25. Figure 7-25

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 ...

Get Professional BizTalk® Server 2006 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.