Git Product home page Git Product logo

apim-testing-with-postman-in-ado's Introduction

APIM testing - configure Postman API tests in Azure DevOps

This example is exporting an already existing API from Azure APIM into postman and configuring Postman API tests in Azure DevOps. For this example I am using demo conference API, which is configured in my APIM instance. Find more details here.

Steps

Export the api from APIM and select postman. You can choose postman for Web or Windows. image

image

This will prompt a dialogue in postman to select a workspace. Once you have selected the workspace, import the api into postman. There is also an option to create collection at the same time and some advanced options

image

Now that the API is exported to postman, configure any pre-request steps, variables & tests in postman. In this example, GetSessions endpoint uses a pre-request step to retrieve jwt-token.

image

There are several variables configured in this example as shown below.

image

The test configured in this example is checking if the API response status is 200. Additional tests can be easily added here , e.g. – tests to check response content, response time etc.

image

After configuration is completed, execute the tests to check if everything is working as expected.

image

Once everything is working as expected, click on the collection and export it. From the dialogue, select Collection 2.1 and save the json file.

image

The exported json file also contains the variables we have configured originally (baseUrl, apiKey etc). I have updated values of these variables with place holders (##apiKey##, ##baseUrl## and created a variable group in ADO ‘DemoConfAPIGroup’ to define the values of these variables. You can link this variable group to a Key Vault to securely save sensitive data. The placeholders in json file will be later replaced with required values from variable group during pipeline execution.

image

Now we have the exported and updated json file, let’s move on to creating DevOps pipeline. To run this collection in DevOps pipeline, we need to use newman CLI tool from postman. We can install this tool using npm command (npm install -g newman). To run the tests, we can use the command newman run DemoConfApi.json. The yaml definition for devops pipeline is in azure-pipelines.yml.

The newman run command comes with a few more parameters, which helps to publish the test results. Please note that the -x flag will ignore the exit code and continue executing build steps in the pipeline. If you want to stop the pipeline execution on tests failure, remove this flag.

Here are the test results after running pipeline:

image

apim-testing-with-postman-in-ado's People

Contributors

grnisha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.