Testing Business Rules
More and more I’m starting to pay attention to the discussions regarding DSLs (Domain Specific Languages). Specifically, I’ve been thinking about business rules as a sort of DSL. Scott Bellware and I have had many conversations about this. To me, how we define business rules is a good example of a Business DSL.
A simple business rule example:
Object Type: Case
Rule Name/Description: Notify all queue members upon dispatch
Start Event: Dispatch
Cancel Events: Accept
Conditions: None
Action Title: Notify Queue Members
Who to Notify: Current Queue Members
Start Action: 0 minutes
From: Event Creation
Using: Elapsed Time
Repeat Every: 4 hours
Repeat for: 999 days
Message: [Object Type] [Object ID] has been dispatched to queue [Current Queue].
Ayende had a recent post that touched on keeping DSLs under source code control, and testing DSLs.
This got me to thinking about an issue we have in Clarify today.
If a business rule is a DSL, then how do we test it?
On a recent Dovetail Forum post, rkelly (Cue “Trapped in the Closet“ music) highlights an all-too-common problem:
At one point, there were 2 other managers (non-it) that were allowed to create business rules but this proved fatal as an incorrectly entered business rule can lock up rule manager.
It’s easy to create business rules that cause havoc. For example, in the example rule I have above, what if the Cancel Event wasn’t specified? The notifications would continue forever. What if the Repeat Every was typed in as 4 seconds instead of 4 hours? Notification overload!
I’ve yet to see anyone test business rules in Clarify, other than manual testing.
(Before my dev and testing team raises hell – yes, we tested tons of business rules using FIT and Fitnesse when we builtDovetail RuleManager – but this required having access to and knowledge of the Dovetail RuleManager assemblies. This isn’t the case at a customer site.)
If there isn’t a way to test business rules in an automated fashion, it’s easy to create a rule that causes havoc, and the knowledge to create them is so high that we don’t let “business” people create rules, then is it no longer a Business DSL? Or maybe its a DSL that business people can read, but aren’t allowed to write?
I know, more questions than answers here.
Comments?