Share this link

    Home / Tradeshift Documentation / Tradeshift Partner Apps / Babelway / Chapter 4. Channels

    Test cases

    2303 0 Created on 2021-01-26 09:45:14; Last updated on 2022-07-01 13:01:37

    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.

    mceclip0.png

    Testing tab list of existing test cases

     

    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:

    mceclip1.png

    Edit test case screen

     

    Change Test Case Type

    You can change the test case type between "Channel , Transformation" as shown below:

    mceclip2.png

    Change test case type

     

    The following parameters can be set according to your setup:

     Id 

     A unique identifier automatically set by the Babelway platform. 

     Name 

     A name that you can set and/or modify to easily retrieve and manage your element. 

     Success 

     Select one of following conditions for testing success:

     if there is no error and it has   been processed by this   channel 

     Test is successful if no error occurred during processing, do the routing rules if routing is checked and   look at the end if the Message Record is in state "DONE" and that the Message Record's channel is the   one where the test case is configured. 

     if there is no error, the output equals the ExpectedMessageOut and it has been processed by this channel 

     Test is successful if no error occurred during processing, do the routing rules if routing is checked,   check that the channel of the message record is the one of the test case and checks if the output file is   the same as the file in the File Property "ExpectedMessageOut". 

     if an error occurs 

     Test is successful if an error occured during processing. This test is used to validate processing   behavior in specific cases and check that an error is properly returned in these cases. 

     if there is no error and it has not been processed by this channel 

     Test is successful if the status of the Message Record is set to DONE but also checks if the channel of   the Message Record is not the channel of the test case (meaning that the message did not generate   any error and it has been routed away from the channel of the test case). This allows you to test that   the routing happens as expected. 

     ExpectedMessageOut 

     Upload message that will be compared to processed message during test. 

     MessageIn 

     Upload message that will be used as input for test. 

    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.

    mceclip3.png

    Success routing condition

     

    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.

    mceclip4.png

    Test case Metadata

     

    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:

    mceclip5.png

    Mapping Metadata

     

    The data will be generated in the output message, as shown below:

    Output Metadata

     

    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.

    mceclip7.png

    Message record

     

    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.
    

    0 people found this helpful.

    Related Articles