Learn Azure Service Bus in 10 minutes in Hindi

 Recently, I created a video on youtube which talks about: Creating Azure Service Bus in Microsoft Azure Cloud Understanding the difference between Basic and Standard Tier Understanding the difference between Topics and Queues Creating a Queue Sending a message on Queue Peek a message and learn how many messages can be peeked Receive a message Check out this Video. Happy Learning :)

Using Newman Client for API Testing - Part 1

Hello Friends,

In this post, I am going to share with you how you can use newman client to test your API(s). I am writing this blog in two parts.
Part 1 Objective:
To be able to use newman client to test API(s)
For this we'll do:
  1. Create an API. You can create the API in any language like .Net, .Net core, php, nodejs. For this sample, I have created an API using NodeJS and express and I have used only the GET API(s) to keep it simple
  2. Test that API(s) once in postman.
  3. Setup Asserts
  4. Export the collection. 
  5. Create a nodejs project or use this github repo
  6. Setup newman. Checkout package.json in the repo.
  7. Test the collection using newman
Part 2 Objective:
To integrate newman in Azure DevOps CI\CD so that our API(s) can be tested automatically as part of CI\CD. We'll discuss the steps in next post.

So, let's get started with our first objective. 
Here is the github repo.
Here are the steps you can follow:
  1. Clone the github repo
  2. Ensure that you have nodejs installed.
  3. In the folder, which contains package.json, run the following command:
    npm install
  4. Install npx globally, so that you can access local node modules using npx:
    npm install -g npx
  5. Open Terminal and run:
    npm run start
  6. You should have an api running at port 3000.

    So, here basically npm reads the package.json and checks out the 'start' in scripts section. This will further read main.js and will have an express js server running at port 3000. Also, you can see the following code which is nothing but an API endpoint.
  7. So, we have a working API running which can be tested in postman or even directly as this is a get only api.
  8. Adding Tests/Asserts. You can do this in Tests Section of each API:
  9. Next, let's talk about the postman collection. I am having a collection added already with name mycollection.json. You can export a collection as shown in the picture below:
  10. Let's try understanding the collection. So, we can see that postman collection is easily readable
  11. To add more tests, you can add in the Postman and can re-export the collection
  12. Open another terminal so that the API is running and run the following command
    npm run test
    So, if you checkout package.json, I have installed newman and when we run npm run test it is running the newman collection. Checkout the 'test' in package.json under scripts section
  13. Yay! The tests-report.txt will be generated which will look like this:
This was easy huh! :) We'll do the CI\CD setup in the next post.