Sitecore Commerce powered by Dynamics AX – Continuous testing on transaction service using postman

Working with Microsoft Dynamics AX and Sitecore Commerce can sometimes be a challenge. Mostly because Dynamics AX installations often includes lots of customization and the way that configuration and setup is handled in AX Databases (Online channel databases).

Dynamics AX push and pulls data and configuration through a number “jobs”, and when that is done, it might break something. But what it breaks is not easy to identify.  The componen/connector that ties Sitecore Commerce to Dynamics AX – the transaction service is where the potential errors will happen. It can be an Add-to-cart not working or all of a sudden or  maybe some catalog configuration wrongly got pushed, or configuration or data around zip code etc. To my perspective – it’s never ever acceptable to just sit and wait for errors to occur. This must be a proactive procedure – we must do all we can to catch any errors before it hit’s the users.

Postman

The transaction service is used from the Storefront through SOAP requests (through Pipelines etc.). Using postman, we can simulate any of those actions – bypassing the Storefront. We can also do a lot of scripting, testing and automation using postman.

Newman

Using Newman, we can run postman collections from a command line. With this we have a simple setup to be able to continuously run tests to the transaction service and verifying that the most important actions works, e.g. Add-to-cart, Get Cart etc. So in case that some configuration changes in the online channel databases, or the RTS service is not responding – we can catch those error through over continuous testing.

How to set it up

First off, you need Node.js as Newman resides in a NPM registry (and on Github). There’s a pretty good guide on how set it up here:  https://www.getpostman.com/docs/v6/postman/collection_runs/command_line_integration_with_newman

Following this guide will give you all needed to have you postman collections running from a command line.

A specific scenario

I my scenario, the Dynamics AX setup is for a retail business where each brick and mortar store have a web property. Each of these stores resides, in the Dynamics AX side in many online channel databases. I want my continuous testing to run a specific scenario for each of these stores repeatedly. To do this I have a CSV file with a store identifier  as well as an AX User Account ID to identify the users that performs each of the following step and simple tests:

  • GetShoppingCart
    1. Check that no errors is returned
  • AddItems – add a specific product to the cart
    1. Check that no errors is returned
    2. Check that the product added is returned as part of the shopping cart returned
  • GetShoppingCart
    1. Check that no errors is returned
    2. Check that shopping cart is NOT empty
  • RemoveItems
    1. Check that no errors is returned
    2. Check that shopping cart is empty now
  • GetShoppingCart
    1. Check that no errors is returned
    2. Check that shopping cart is empty

To run the tests is very simple:

Open you Node.js Command prompt and navigate to the folder where you have you postman collection and your csv file. Use a command line like this:

newman run some_collection.json -d some_data.csv --bail

The -bail will stop the execution of the script in case an error occurs. There’s also a -n argument so you can ask newman to run your script n number of times.

The command line will look something like this (if you don’t put the –silent argument on it:

In case the scripts fails, executing will stop due to the –bail argument and a result like the following will show:

Alerts and monitoring

There’s several options on how to get alerted. Since its running postman it’s open on what you can do. You can send requests to slack or MS Teams. Pretty must everything be possible if you just need to do a get or post request to an end-point.

Another option is to use the monitoring offered by the postman team – check it out here: https://www.getpostman.com/docs/v6/postman/monitors/intro_monitors

A final word

If you’re looking for other hints and tools when working with a Sitecore Commerce and Dynamics Setup – take a look at another Blog post on that here: http://blog.alpha-solutions.us/2018/08/sitecore-commerce-and-microsoft-dynamics-ax-useful-tools-and-hints/

In case you find any of this useful and need more detail – please reach out to me or any of my colleges at Alpha Solutions.

Follow me on Twitter: and follow Alpha Solutions:

 

Sitecore Commerce powered by Dynamics AX – Continuous testing on transaction service using postman

Leave a Reply

Your email address will not be published. Required fields are marked *