Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Running Tests on Deployment

DZone 's Guide to

Running Tests on Deployment

A member of the mabl team walks us through how to use their platform to make sure your API integrations went off without a hitch.

· Integration Zone ·
Free Resource

Integrating testing at every step of the DevOps pipeline helps us deliver the high-quality user experience we all strive for. We refer to this practice as DevTestOps, and, in this post, I will share some improvements we've made to mabl to provide you with more control over testing your Journeys on deployment using the Deployment Events API, which we also use as part of our Codeship build process.

Having automated tests that trigger on deployment helps developers to quickly validate that new code didn't cause any regressions as it makes its way across environments such as staging and production. It also gives peace of mind to QA engineers, product managers, and other business stakeholders that any issues are proactively resolved and everything continues to operate as expected. Some issues may only become evident in a production environment, so it's great when our tests can run on every deployment.

Here's what's new to the mabl Deployment Events API, or deployment API for short.

The Power of Labels

Labels are a great way to organize your mabl Journeys and Plans. For example, you can use labels to separate Plans that run smoke tests, feature tests, responsive design tests, etc. The automation power of labels lies in the ability to control which Plans execute in response to a deployment event by passing them as parameters to the deployment API. For example:

{
 "environment_id" : "your-env-id",
 "application_id" : "your-app-id",
 "plan_labels" : [ "smoke", "login" ]
 ...
}

In this example, only Plans containing at least one of the "smoke" and "login" labels will be executed. An easy way to test what will happen on deployment is to use the curl command builder to call the API.

(Note: If you don't see the same thing in your mabl environment as the screenshot above, this is because the above screenshot was taken from our dev environment. The Labels drop-down will make its way to production early next week.)

Here's what the generated curl command looks like with labels:

curl -s 'https://api.mabl.com/events/deployment' \     -u 'key:[YOUR_API_KEY]' \     -H 'Content-Type:application/json' \     -d '{"environment_id":"[YOUR_ENV_ID]","application_id":"[YOUR_APP_ID]","plan_labels":["smoke","login"]}'

In addition to labels, you can also use the deployment API to rebase the visual change models for the application or set a fixed baseline to compare against.

Creating a Fixed Visual Diff Baseline

There are times where you would like to review all visual changes, including dynamic content, that have occurred in the application UI after a given release. In such cases, you can use the deployment API to quickly create a new, fixed baseline for visual change detection by using the "Set as fixed baseline for visual change models" toggle in the curl command builder.

Note that in this case, you shouldn't toggle "Rebaseline visual change models" which will cause mabl to start rebuilding its visual models accounting for dynamic content areas and you will see results after several journey runs.

You can use the resulting curl command to trigger a new journey run for all Plans matching the command. This will capture new UI screenshots that will serve as a fixed baseline for visual comparison of subsequent journey runs. In that case, mabl will use the fixed baseline to highlight all visual diffs, including dynamic content areas, and present them to you for review. Thus, you can make sure that all visual changes are intentional and quickly identify anything that needs fixing.

To learn more about the deployment API, check out the docs and the following on-demand webinar. You can find the accompanying webinar slides on SlideShare. 

Topics:
integration ,apis ,api integrations ,integration testing ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}