Test Action Chains

You can use the Tests editor–located on the Action Chain editor’s Tests tab–to implement a test-driven development approach to designing, creating, and maintaining your action chains, or to implement your own methodology. Using the Tests editor, you can easily define test cases for an action chain and run them at any time, to ensure that code changes haven’t broken any functionality.

The Tests editor removes the need to manually code a test for each code path by:

When testing action chains, the first thing you should do is figure out all of the possible code paths, since each one is a scenario that needs to be tested to achieve full test coverage. More complex code paths, however, might have more than one scenario that should be tested.

After identifying the code paths, create at least one test for each, depending on how many scenarios there are for a path. For each test, you need to:

The goal is to fully test your action chain by testing each of its code paths. If your tests cover the expected results for each code path, the value for Coverage will be 100%.

In the example below, three tests have been created for the three code paths that need to be covered to achieve full test coverage: Addition Test, Invalid Operator Test, and the Subtraction Test. Therefore, the value for Coverage is 100%, as you can see in the upper left corner of the editor.

For the Addition Test, which tests the if operator_ip === '+' code block, you can see the three input parameter values in the Parameters section of the Properties pane. The expected results are in the Expectations section.

The source code for all of your tests is stored in a separate JSON file, actionchainname-tests.json, for easier maintenance. To view this file’s contents, click JSON in the left pane. You can also find this file under the artifact’s chains folder in the Navigator’s Source View tab.