Defining test cases in FlowEngine flows

In this post we are going to show how to define test cases within the FlowEngine, without copying flows, changing links or making any modifications to the flows in production.

This is as easy as following these steps:

1.- Install the node «node-red-contrib-flow-asserter»

To do this, navigate to the «Manage palette» menu.


Once the menu is displayed, look for the node with the name «node-red-contrib-flow-asserter».

2.- Define a test flow

Simply, create a flow according to our needs. For this example, you are going to create a flow that inserts data in an ontology:

3.- Add the node «flow-asseter out node»

This node defines where the evaluation of the tests is performed. In this example, we want to evaluate whether the insertion has been successful or not. To do this, place it after the INSERT node.


If the test evaluation is triggered, the message will not be sent to the next node (debug msg), but will instead go out through the bottom output of the «flow-asserter in» node. When the flow is executed normally (not during the tests), this node is ignored.

4.- Define the test cases by adding a «flow-asserter in» node



This node has two outputs. The upper one, which connects to the flow to be tested and generates a test case message; and the lower one, which will show the result of each test case. Within the node, you can define as many test cases as needed:

The «input» field represents the value that will travel in the «msg.payload» for the test. The remaining two fields define how to compare the result of the msg.payload in the «flow-asserter out» node to determine whether the test is successful or not.

In this example, you will define two tests:

  1. Send a valid ontology instance to insert: so you can expect that, as a result, you will have a list of IDs. In that case, the check will be that the result of the insertion must have the string «ids».
  2. Send an empty ontology instance: which will cause the insertion process to fail. As a failure check, look for the response to contain the string «Error processing data». Also link this node to the «flow-asserter out» by selecting its ID in the «flow-asserter out node» field.

Running the tests

Save the changes by clicking on the «Deploy» button.


Test the test execution. Click on the left tab of the «flow-asserter in» button, and launch the different test cases:


Each test case generates a message in the flow, the results of which you can see in the second output:

You can even change the output so that it inserts the output of the tests in your user’s audit ontology:

And you can query it, for example, from the Query Tool

Test normal execution

If you launch the flow normally, the test nodes will be ignored, so everything should work normally. Note: Bear in mind that each node executed with the tests will persist its operation as if it were a normal execution.

You can find more information about the node HERE.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *