Generating Test Classes

This section explains CER's support for generating rule set test classes. We can test our Sample Benefit rule set using this support. For this example we will look at the "Eligible Person" Rule.

The Person class has 2 attributes which need to be specified in order to calculate the eligible attribute for a person.
  1. age - a number to hold a person's age.
  2. isStudent - a boolean to indicate if the person is a student.
The Person has a derived attribute as below.
  1. eligible - a boolean to indicate if a person is eligible for "Sample Benefit"
The following steps show how to run the CER Test Code Generator on the SampleBenefit.xml which we extracted in Extracting Rule Sets from the Database for Testing.
  1. Open a command prompt in your Curam/EJBServer directory.
  2. Run build creole.generate.test.classes to generate test classes from your rule set. This target runs on the rules sets in the CREOLE_Rule_Sets directory for each component.
  3. The CER code generator will place its output in the EJBServer/build/svr/creole.gen/source directory, refresh your development environment to view this.
The generated code is only intended for use in test environments where it is a straightforward matter to recompile changes to code. The generated code is not portable across machines, as it contains absolute paths to the rule sets on the local machine. In particular, you must not use the generated code in any production environment where rule sets may change dynamically.
Tip: You should regenerate your test classes if you make structural changes to your rule sets e.g.

You do not need to regenerate the test classes if your changes are limited to the implementation of a rule attribute (i.e. its derivation expressions). The derivations are always processed dynamically from the rule set at run time and are not present in the generated test classes.