How to Transform Test Messages by XSLT

USE:

It can happen that during, for example, migration projects, field names or the structure of the payload may change. The new interface can also generate values in a different order. To execute test cases in such scenarios, you can take advantage of the transformation functionality.

XSLT Transformation can be applied on both Input and Output payloads and will be stored in a reference test case. This test case will be used afterward in Automation Object Configuration.

Apart from the example below, there is a separate page with the most common solutions: XSLT transformation use cases

EXAMPLE:

Let’s take as an example Interface for Sales Order creation. For some reasons, the structure of the payload message was changed:

  • the node ‘Quantity’ is now reflected by the node ‘Qty,’

  • the node ‘ProductName’ is now reflected by the node ‘Product’.

If we execute such a test case (with a different payload structure), it will surely fail since Qty and Product fields are not mapped correctly:

Differences between the Reference and Current Execution:

We can apply an XSLT transformation to solve this issue.

PROCEDURE:

In our case, we need to apply the XSLT mapping to the input message. As mentioned previously, this can be achieved by transformation settings for Automation Object.

  1. Prepare the XSLT mapping for a message. Create a test case with type XSLT Transformation and copy your prepared message mapping to the content of the test case. Our example transformation:

    Save the content and the test case.

  2. Open Automation Object configuration and go to XSLT section
    There are four parameters for XSLT transformation:


Choose parameters based on your requirements (you can use all of them at the same time). In our example, we are using Execute XSLT on input payload as we need to apply a transformation to the input payload.

Let’s execute our main test case once again (with XSLT transformation).

The test case has been executed correctly. As you can see in the Execution Information input message was mapped by the XSLT program, which is stored in test case 17461.

Using appropriate XSLT mapping, you can solve many issues with differences between XML structures in input/output payloads.

Variables & Variable processing can be used in the XSLT. Define <xsl:param> with name equal variable name and you can use this variable in the XSLT code. For example:

<xsl:param name=”variable_name”>

 

 

© 2017 - 2022 Int4 AG All rights reserved