FIT for rules

Keep your business rules in shape


Built on FIT


This is an example fit document that also describes how fit-for-rules works. Fit-for-rules aims to provide a framework to functionally test your rules. As with the FIT ( philosophy, the aim is to allow collaboration between domain experts and developers in specifying rules logic in a test driven fashion.


Moreover, it allows these “acceptance criteria” to become automatically executable tests that can become part of a test suite that regression tests rules (rule can change often, so it’s good to have a baseline of tests). The documents are ideally documentation mixed up with the test data (which is tables) – for multiple scenarios that the rules may need to deal with. They could also be used to do “what if” scenario testing (with old or new rules).


·        First step is to setup the objects that will be used in the rule.

o       1st column is Class

o       2nd is the name that instance will be referred to

o       3rd is for (optional) constructor (can be another object, or a static field to initialize)

o       It will create new instances for each object declared









·        Second step is to populate the objects that were declared in the first step.

o       1st column maps up with the object name

o       2nd column is a method (spaces and case are ignored – typically set method)

o       3rd column is the value (it will convert it as appropriate)

o       It can also cope with method parameters by using “(“ braces “)”




Set age



Set number of accidents



Set name




·        Third step is to invoke the rule engine

o       Provider sets up the JSR-94 provider (URI, provider classname).

o       Ruleset loads the ruleset (takes a url, or a path to a file, classpath etc)

o       Assert pushes the object into the rule engine (use “All” if you want all of them).

o       Execute fires the rules
















·        Fourth step checks the results, by comparing actual values with expected values (values are accessed from the objects that were setup in the first step).

o       1st  column is the object name from first step

o       2nd column is the getter method (indexed getters are supported with “(“ )

o       3rd column is the value (with appropriate auto type conversions).




Get Name



Is Approved



Get Age




·        You can optionally reset the domain objects, in case you want to do multiple clean test runs in the one test document



·        With FIT, you can get a summary printed in the output report by using the following table



counts 32 right, 0 wrong, 22 ignored, 0 exceptions
input file C:\Projects\fit-for-rules-new\doc\fit-for-rules.html
input update Thu May 11 20:23:13 EST 2006
output file C:\Projects\fit-for-rules-new\doc\test-result.html
run date Thu May 11 20:23:51 EST 2006
run elapsed time 0:01.28



You can use Word, Open Office, Excel etc – any thing that can output HTML tables.

After executing, review the resulting report.


For download, see the project homepage


© Michael Neale 2006

You can reach me on the Drools mailing list.


FAQ: why is this HTML so messed up? Because it came from MS Word, just like a FIT test would (it is a fit test document!). You may get better results with Excel, or Open Office, but it doesn’t matter, FIT copes.