Testing Rules
Testing rules is a critical part of the rule development process. Rulebricks provides powerful testing capabilities that allow you to ensure your rules are working as expected before you publish them.
Testing rules is extremely straightforward, since we're really only asking one question: Given certain input data, does the rule return the expected output?
Testing in the Rulebricks Editor
Open the rule editor
To test a rule, open the rule you want to test in the Rulebricks editor, open the sidebar, and click the "Test" tab.
You'll notice there are two test modes available: "Single Request", and "Suite".
Single Request
In "Single Request" mode, you can test your rule with a single request object. This is useful for testing your rule with a specific set of data, particularly as you're building out your rule.
To test your rule with a single request object, simply paste a particular request object you're interested in handling into the JSON text editor, and click "Test".
You'll see the result of the rule displayed in the "Results" section, along with a detailed breakdown of the rule execution represented visually on the decision table.
Cells that are green represent conditions that were met, while cells that are red represent conditions that were not met. Yellow cells represent the results of the rule that your rule returned.
It is possible at this step you encounter an error, which likely means you do not handle the data you provided in your rule.
Suite – Regression Testing
In "Suite" mode, you can test your rule with multiple request objects at once. This is useful for testing your rule with a variety of data, and ensuring it behaves as expected in a variety of scenarios.
This mode is particularly useful for regression testing, where you want to ensure that changes you make to your rule don't break existing functionality.
Because you may want to upload a large number of test cases at once, we have API endpoints available to assist with mounting test cases into any Rulebricks rule or flow.
Otherwise, a quick way to build out a testing suite is to copy and paste a variety of request objects into the JSON text editor under "Single Request", click "Test", copy the result, and save a new test case in Suite mode using the results, alternating between the two modes to generate payloads.
Continuous Testing
You can ensure all tests in your rule/flow run automatically before publishing new releases of your rule by enabling "Continuous Testing" in the "Settings" menu of your rule/flow found by clicking the gear icon from within the rule/flow editor at the top right. Tests in your suite marked as "Critical" will then prevent new versions of assets from being published if they fail.
When this feature is enabled, you will also see a score next to every published version of an asset. This score is a percentage of tests that passed in the suite for that version, and helps you understand the integrity/coverage of every given version of your rule/flow.