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:
- Run the
mvn installcommand to build your decision or task model. - Open the
<model>/target/classes/META-INF/decisionsfolder. - Open the JSON file that is located in this folder.
- Identify and copy the value of the
nameproperty. 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
.