A replacement for Postman?
This week I saw a video on YouTube video which peaked my interest. The video title was ‘I don’t need Postman anymore!! I use VS code instead…’ Now, I love API testing and I’m a huge fan of Postman, so naturally I wanted to find out more.
In the video, James Q Quick talks about how he’s started using Thunder Client, A REST API client available as a VS Code plugin. I immediately wanted to give it a try, so I did. In the remainder of this article, I’ll explain how to get started with Thunder Client and compare it with Postman.
As I mentioned previously, Thunder Client is a VS Code Extension, so to install it you we need to search for it in the VS Code market place and click install.
Once installed we can see the Thunder Client icon as one of the menu options
Cool, once installed, click on the icon to open the GUI. To create our first test click on the New Request Button.
Suppose you’ve used Postman (or another REST Client) before; you’ll probably be fairly familiar with the screen layout. There’s a place to supply the request method, the endpoint and all the required request details, and of course, an area to view the response.
Sending a request
Before going any further, we need something to test. For this tutorial, I’ll be using the Mars Weather Service API from NASA. It’s completely free to use, but you will have to sign up to get an API key – see here for details (https://api.nasa.gov/).
The Mars Weather API is a simple GET request with 3 query parameters
To run it we can past the following endpoint into the Request url field, remembering to replace DEMO_KEY with your generated API key
You will notice that the query Parameters are auto populated based on the url.
When everything is set, we can go ahead and run it by clicking the Send button.
Perfect, all being well, we should get a response back in the response pane.
You’ll also see that the request is captured in the Activity section of the screen. If you want to replay requests in the Activity list, click on the one you need, and the request will be reloaded, along with the received response.
Now we have a request, we can write some tests for it, that way we can validate the response. To write a test, we need to go to the Tests tab on the Requests pane to input our request URL.
From this tab we can add some pre defined tests to validate http status code, response times, header values and even content in the response body. Let’s add some.
First, let’s validate that we get a 200 status back. From the Select dropdown, pick ResponseCode, change Action to equal and then set the value to our expected code, in this instance 200.
Before we run the test again, let’s add one more. Let’s validate the season value from the first json object is set to spring.
To do this, we can select a JSON query from the select dropdown. This allows us to provide the JSON path to our value. Once again, we’ll use equal and then set the value to spring, like so.
Now we have some tests, let’s rerun it and see what happens. Once run, navigate to the Test Results tab on the Response pane. Good news! Everything has passed.
If they fail you’ll see something like this instead.
Again, if you’ve used Postman before you’ll be familiar with collections, if not, collections are a way of managing and storing a suite of tests. To create a collection in Thunder Client, click on the collections option in the left-hand pane and select New Collection from the menu.
We can add the test we’ve already run to our collection by going to the Activity and selecting the ellipse (…) for our request and select Save to Collection.
Now we can name our test and select the collection. Now we have a test in our collection.
I’m genuinely impressed. OK, so Thunder Client does not have all the bells and whistles that Postman has, but if you need all those features like mocking, pre-request scripting, and data-driven testing, you can use Postman. Instead, if you want a lightweight REST client, Thunder Client is a great choice!
Where Thunder Client excels is when you’re already using VS code. If you’re writing automated tests in VS Code or writing an application, then having a client close by exploring and testing API’s is super useful.
So, will I be using Thunder Client again, definitely. Do I think it is a replacement for Postman, No but there is no doubt a place for both of these tools in the market.
I’d love to hear your experiences of these tools or any other tools you use for API testing.
Leave a Reply