Jan 18, 2021

API Testing 'A Beginners View': How to receive notification of POSTMAN Test execution completion in GOOGLE CHAT ROOM

Google chat API is an interesting API that lets you to get notification of the Test Scripts execution completion for every run. Just install GOOGLE CHAT in your machine and follow the below steps and that’s it

Steps to it:

  1. Create a room in Google chat (Addin the member's list).

  1. Room is setup:

  1. Select “Manage webhooks” as displayed below:

  1. Type any name as per your need and click save:

  1. Copy the link to the Clipboard. Open your collection/folders, just add this as a new POST request to the existing ones.

  1. Click on  “Send”:

In this BOT you can add some Test Scripts based on the previous requests execution status to showcase the Test Report.


Sample is below:

var resp = JSON.parse(responseBody);

console.log(resp);

  //Checking the Response Status Code

    pm.test("Response is Successful with Status Code 200", function () 

    {

    pm.response.to.have.status(200);

    console.log("Response is Successful with Status Code 200");

    });

// this counter is from previous step (in your script need to define it)

to check the completion of run

 const counter_check = pm.environment.get("counter");

 if(counter_check == 10

 {

     pm.test("Execution Passed" , function () 

        {

        console.log("Execution Passed");

        });

 }

 else 

    {

        pm.test("Execution Failed" , function () 

        {

        pm.expect.fail('Execution failed, please check test results of previous steps');

        });

    }

 

Happy Learning 😇

Hope this was useful 😇

No comments: