Understanding unit test cases

A test case identifies one or more testable conditions (assertions) that are used to determine whether a rule returns an expected result. Reusable test cases support the continuous delivery model, providing a way to test rules on a recurring basis to identify the effects of new or modified rules.

You can run test cases whenever code changes are made that might affect existing functionality. For example, an account executive wants to ensure that a 10% discount is applied to all preferred customers. You create a test case that verifies that this discount is applied to all preferred customers in the database. The test case test fails if there are any preferred customers for which the 10% discount is not applied. You then add a new preferred customer to the database and run the test case to make sure that the customer is correctly configured to receive the discount and that the discount for other preferred customers is not affected.

Additionally, you can group related unit test cases into a test suite so that you can run multiple test cases and suites in a specified order. For example, you can run related test cases in a regression test suite when changes are made to application functionality. For more information about test suites, see Grouping test cases into suites.

After you create test cases and test suites, you can run them in a CI/CD pipeline for your application by using Deployment Manager or a third-party automation server such as Jenkins. For more information, see Understanding continuous integration and delivery pipelines.

You can use unit test the following types of rules:

  • Activities
  • Case types
  • Collections
  • Data pages
  • Data transforms
  • Decision tables
  • Decision trees
  • Declare expressions
  • Flows
  • Map values
  • Report definitions
  • Strategies
  • When

Typically, you unit test a rule, and then convert it to a test case. For flow and case type rules, you record the test case.