Testing allows you to easily test channel operations to validate it before deployment. Ideally, all channels should include a few basic test cases to confirm that their configuration covers the basic use cases.
After configuring a channel, its operations should be tested. This is done by creating and running test cases. In doing this, you feed your channel with test input files and confirm that the channel produces the expected output results.
When running a channel test case, message in, transformation and message out processes are executed and tested in real conditions. Only the gateways cannot be validated since they require exchanges with external parties.
The testing tab displays a list of test cases defined for the selected channel. You can edit a test case by clicking on its name in the first column. Click on Create New to create a new test case. Both these operations open the Create Test Case screen described here under.
In the same table, you can select test cases by checking the text box in each line. By clicking on Run selected you will trigger a run of each of these test cases. The results will later be visible in the Message Record screen described here under.
You can also delete a selection of test cases by clicking on Delete Selected.
Edit Test Case
When you create a new test case or edit an existing one, you will reach the following page:
Change Test Case Type
You can change the test case type between "Channel , Transformation" as shown below:
The following parameters can be set according to your setup:
Note: The status of the message is different than the status of the test, Message status: contains the status of the message itself, Test status: contains the status of the test, based on the Success condition.
Test routing rules using test case
When we create test case to test the routing rules we will select test case type of "Channel" in order to be able to test the routing before deploying it, And we will control the success routing condition to set the status of the test to be success if the message is processed by this channel or if the message is processed by another channel in the "Success condition" section.
Note: The Success routing condition is the condition on the routing that must be fulfilled so that the test is considered as successful.
Add user defined metadata in the test case
We can create a user defined metadata in the test case. This is useful for example if we want to mimic a user defined metadata that is sent from the first channel to this channel. The example below shows how to create a user defined metadata in a test case to mimic the actual logic for the channel that is to receive a user defined metadata from the first channel and map this user defined metadata in the mapping (there are so many scenarios in which we can use the user defined metadata in the test case; this depends on the logic which the channel is designed for).
From the test case in the "Input" section, click on the icon related to the "Metadata" field to generate two empty fields.
The first one, on the left, is used to define the user defined metadata name. The field on the right is used to define the user defined metadata value, as shown below after we have added the two fields' values with the proper values for testing.
Note: To make sure that the user defined metadata name is defined properly in the test case you will need to use "user-defined-property:" before the user defined metadata name which in this case is "TestMetadata", as shown above.
Now in the mapping we have used the metadata() function to get the value of this user defined metadata, as shown below:
The data will be generated in the output message, as shown below:
The ability to define a user defined metadata in the test case is very helpful in testing the channel.
Note: You can define and use the user defined metadata in the test case to test your channel based on your channel logic.
Message Record
The following message details screen is displayed upon running a test.
From here, you have access to all the message files such as in and out messages in defined format as well as processed in and out XML messages.
The Status field indicates if message processing was successful or not. Next to it, between brackets, the test result is added as Test Successful or Test failed.
All existing tests will be run at channel deployment time. If at least one of them fails, deployment will be aborted.