Achraf Ben Alaya
No Result
View All Result
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
  • Cloud
  • Motivation
  • General Tips & Fix
  • Exam Preparation
    • AZ-104
    • AZ-400
  • About
    • Resume
SUBSCRIBE
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
  • Cloud
  • Motivation
  • General Tips & Fix
  • Exam Preparation
    • AZ-104
    • AZ-400
  • About
    • Resume
No Result
View All Result
Achraf Ben Alaya
No Result
View All Result
ADVERTISEMENT
Home

Configure postman / newman API tests in Azure DevOps

achraf by achraf
October 25, 2021
in Azure, Blog, Cloud
3 min read
0
Configure postman / newman API tests in Azure DevOps
0
SHARES
2.2k
VIEWS
Share on FacebookShare on Twitter

Postman is one of the greatest tools ever to test your API, I have always been testing everything I have created first and always with the postman.
For this demo,  and before we start configuring our pipeline we have to create a collection so that we can use it in our pipeline.

This article will explain step by step how :

  • Create API Project (Net 5)
  • Create And Export Postman Collection
  • Create Azure Pipeline

Add new Man script / export test results

Create API Project (Net 5) :

To demonstrate our flow we are going to use the default template provided by the API project that contains a weather controller .
As you can see we have our list here now, that contains data about weather, now it’s time to test this with the postman and create the tests.

Create And Export Postman Collection

First of all, we need to install a postman.
Next , in order to retrieve our list , we are going to create a get request  :

http://localhost:7173/WeatherForecast

Now as you can see we have a status of 200 OK and we have 5 items as result , now we are going to create a simple test that will make sure our list must return 200 ok and the count of 5 objects .
Now ,In test Tab we are going to insert the follow code :

var jsonResponse = pm.response.json();
pm.test("5 results are returned", () => {
    pm.expect(jsonResponse).to.have.lengthOf(5);
    //pm.environment.set("variable_key", "variable_value");
});

pm.test("Http status 200", () => {
    pm.response.to.have.status(200);
});

Now , we now our list return 5 items , if for example our list should return 4 item and we return 5 we should get as result :

Now it’s time to export our collection .
To do that , right clique on the collection and clique on export :
When exporting the collection we will have a JSON file that we are going to use later in our pipeline.
Now we are done with our postman collection it’s time to create the pipeline.

Create Azure Pipeline

Now in the last step we are going to create our azure pipeline, for that I will share the code below :

trigger:
- master

pool:
  vmImage: ubuntu-latest

steps:
    - task: CmdLine@2
      continueOnError: true
      inputs:
      
        script: |
         sudo apt-get install -y bash
         sudo npm install newman --global
         newman run ./demonewpan/postmancollection/Testing.postman_collection.json  --reporters cli,junit --reporter-junit-export junit-report.xml         
         sleep 40
    - task: PublishTestResults@2
      displayName: 'Publish Test Results for postman'
      inputs:
       testResultsFormat: 'JUnit'
       testResultsFiles: '**/*.xml'
       mergeTestResults: true
       failTaskOnFailedTests: false

And as we can see the pipeline was built successfully and the result of the test is published and we can find them in the test tab.

And as we can see we have published the result on Tests Tab.

This was all about adding the Newman Tests to our pipeline.

ShareTweet
Previous Post

Run background tasks with WebJobs in Azure App Service

Next Post

Tools I use with Database

Related Posts

Switch to Azure Container Registry from Docker Hub
Azure

From Docker Hub, switch to Azure Container Registry & AKS

January 16, 2023
132
How to setup nginx reverse proxy && load balancer for aspnet core apps with Docker and azure kubernetes service (AKS)
Azure

How to configure an ingress controller using TLS/SSL for the Azure Kubernetes Service (AKS)

November 25, 2022
229
How to setup nginx reverse proxy && load balancer for aspnet core apps with Docker and azure kubernetes service (AKS)
Azure

How to setup nginx reverse proxy && load balancer for aspnet core apps with Docker and azure kubernetes service (AKS)

November 23, 2022
102
How to setup nginx reverse proxy for aspnet core apps with and without  Docker compose
Azure

How to setup nginx reverse proxy for aspnet core apps with and without Docker compose

November 23, 2022
153
Win free certifications at the Microsoft Build Cloud Skills Challenge | May 2022 🎁
Blog

Win free certifications at the Microsoft Build Cloud Skills Challenge | May 2022 🎁

May 28, 2022
107
Generating report for SSL Certificates for Websites with PowerShell
Azure

Generating report for SSL Certificates for Websites with PowerShell

April 10, 2022
386
Next Post
Tools I use with Database

Tools I use with Database

Leave a Reply Cancel reply

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

Terraform

Certifications

Microsoft certified trainer (MCT)

Recommended

Finally a stable version of Xamarin.Forms 4.1.0 and announcing Xamarin.Essentials 1.2

Finally a stable version of Xamarin.Forms 4.1.0 and announcing Xamarin.Essentials 1.2

April 21, 2020
378
Blazor Write C# instead of JavaScript to Build a Client-Side Single-Page App

Blazor Write C# instead of JavaScript to Build a Client-Side Single-Page App

April 19, 2020
460
My book collection for 2020-2021

My book collection for 2020-2021

December 28, 2020
336
How to SSH into AKS Nodes

How to SSH into AKS Nodes

May 11, 2021
3.8k
Generating report for SSL Certificates for Websites with PowerShell

Generating report for SSL Certificates for Websites with PowerShell

April 10, 2022
386
How To Send Mail Using SQL Server

How To Send Mail Using SQL Server

April 20, 2020
208
Facebook Twitter LinkedIn Youtube
Switch to Azure Container Registry from Docker Hub

From Docker Hub, switch to Azure Container Registry & AKS

January 16, 2023
How to setup nginx reverse proxy && load balancer for aspnet core apps with Docker and azure kubernetes service (AKS)

How to configure an ingress controller using TLS/SSL for the Azure Kubernetes Service (AKS)

November 25, 2022
How to setup nginx reverse proxy && load balancer for aspnet core apps with Docker and azure kubernetes service (AKS)

How to setup nginx reverse proxy && load balancer for aspnet core apps with Docker and azure kubernetes service (AKS)

November 23, 2022

Categories

  • Apps (1)
  • Azure (39)
  • blazor (2)
  • Blog (62)
  • c# (7)
  • Cloud (37)
  • Dapr (4)
  • docker (3)
  • Games (1)
  • General Tips & Fix (1)
  • motivation (2)
  • Motivation (3)
  • News (9)
  • Resume (1)
  • sql (4)
  • Tricks, Tips and Fixes (3)
  • xamarin (5)
No Result
View All Result
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
  • Cloud
  • Motivation
  • General Tips & Fix
  • Exam Preparation
    • AZ-104
    • AZ-400
  • About
    • Resume