Achraf Ben Alaya
No Result
View All Result
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy
SUBSCRIBE
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy
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
3.5k
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

Azure

Honored to be recognized as a Microsoft Azure MVP for 2025-2026

July 20, 2025
24
AI

Model Context Protocol (MCP): The Future of AI Integration

April 21, 2025
193
Azure

Step-by-Step Guide: Azure Front Door + Storage Account Static Website + Custom Domain with Terraform

March 11, 2025
501
Network Security & Route Tables – Checking NSGs, route tables, and service endpoints for a targeted VNET or Subnet
Azure

Network Security & Route Tables – Checking NSGs, route tables, and service endpoints for a targeted VNET or Subnet

February 3, 2025
162
Understanding Generative AI and RAG Benefits
AI

Understanding Generative AI and RAG Benefits

January 12, 2025
119
Azure Communication Services Email Sending Simplified: From Setup to Execution and Monitoring
Azure

Azure Communication Services Email Sending Simplified: From Setup to Execution and Monitoring

December 8, 2024
1.9k
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

Azure Automation :  How to create PowerShell Runbook

Azure Automation : How to create PowerShell Runbook

February 4, 2021
1.1k
Block the default URL assigned to the azure web app using azure application gateway

Block the default URL assigned to the azure web app using azure application gateway

May 31, 2023
600
Tools I use with Database

Tools I use with Database

November 7, 2021
808
The Differences Between Blazor Server And Blazor  WebAssembly

The Differences Between Blazor Server And Blazor WebAssembly

January 10, 2021
827
Reading Excel file in Azure Web Apps

Reading Excel file in Azure Web Apps

December 1, 2020
1.8k
Background Tasks With Hangfire And .Net 5

Background Tasks With Hangfire And .Net 5

January 25, 2021
3k
Facebook Twitter LinkedIn Youtube

Honored to be recognized as a Microsoft Azure MVP for 2025-2026

July 20, 2025

Model Context Protocol (MCP): The Future of AI Integration

April 21, 2025

Step-by-Step Guide: Azure Front Door + Storage Account Static Website + Custom Domain with Terraform

March 11, 2025

Categories

  • AI (2)
  • Apps (1)
  • Azure (64)
  • blazor (2)
  • Blog (91)
  • c# (7)
  • Cloud (66)
  • Courses (3)
  • Dapr (4)
  • docker (4)
  • Games (1)
  • General Tips & Fix (1)
  • Home (1)
  • Kubernetes Service (AKS) (1)
  • motivation (2)
  • Motivation (3)
  • News (9)
  • Resume (1)
  • sql (4)
  • Terrafrom (1)
  • Tricks, Tips and Fixes (4)
  • xamarin (5)
No Result
View All Result
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy