Unit testing

You can define unit test scenarios that run automatically at build time to validate your decisions.
Restriction: You cannot run unit tests on predictive models or other models that call predictive models.

You can either run tests locally in a CI/CD stack, or directly in Decision Designer.

Where to define test scenarios

Unit test scenarios are defined in the source folder of the decision service. They must be stored in the following directory: src/test/resources/<functionID>.

The functionID is the identifier of the function that you want to test. It corresponds to the model name and the function name separated by an hyphen, for example LoanValidation-loan-validation-decision-model.

You can go through the following steps to determine the correct functionID for a given model:

  1. Run the mvn install command to build your decision or task model.
  2. Open the <model>/target/classes/META-INF/decisions folder.
  3. Open the JSON file that is located in this folder.
  4. Identify and copy the value of the name property. This value corresponds to the functionID.

Example

For a complete example of how defining and running unit tests, see the Testing a decision service at build time sample available on GitHub External link opens a new window or tab.