You are probably considering or doing various tests for your latest critical API project. This can go from unit to integration tests.

Great! You also want to test the behavior of your API once it’s connected to your front end by a dedicated team. You plan to test it right from your UI.

However, you don’t feel confident enough to ship your product even though you and your QA team have tested various aspects there.

Why? Because you don’t know how it behaves in the real world when it’s out for your consumers.

To understand why you don’t feel confident, let’s look at some failures your API could have at some point:

Long API response times

You might get outdated responses from cache

External services are not available

Worst of all: you don’t get the expected response

It’s pretty hard to measure these things in production without anything covering your back. You will probably know about it when your consumer eventually reports it or when you dig deep in your logs.

To mitigate this, you could gear up with additional testing. If we look into the Agile Testing Quadrants, you are probably able to strike out those approaches you are already doing.

We want something that is criticizing our product and supporting the team. Based on the testing quadrants our best choice is to go with technology faced approaches, a perfect split between automated testing and tools that support our development journey.

Many tools can assist to achieve this task. You are probably looking for something free, well documented, easy to use and feature-rich, yet something lightweight. Loadmill for instance has a free tool to run Automated API and Load Tests with ease and without the need to revamp your whole API project.

To get started, you can simply sign up for a free plan on Loadmill’s site. After you have signed up, go to your API Tests and create your first Test Suite.

A short rundown of all features:

In Flows you can create individual Flows that execute requests one after another. For each request, you can set additional headers, provide validation parameters and assign variables in your current test session.

Based on Flows, you can set a Login Flow that gets executed each time you access a route that requires some sort of authentication. You don’t need to re-authenticate each time you are executing specific requests.

Parameters allow you to set session-wide parameters for your Test Suite. These can be changed during runtime. This is helpful if you like to store certain tokens or simple parameters such as IDs and so on.

The CI section instructs you on how to run API tests in CI environments. Loadmill comes with an npm package. You just need to run it accompanied with your Test Suite’s token.

This is all you need to know about Loadmill’s API Testing features.

Action Time

Let’s get our hands on. For this, we are going to use our beloved API, GitHub’s API, so you don’t need to set your environment just yet for the scope of this quick introduction.

What do we want to do? We want to query our organization and its repositories and dig into details. For this, we want to be as flexible as possible and allow ourselves to swap out certain parameters like the organization’s ID. We also want to measure response times and set parameters during runtime.

First things first, let us store the organization as a parameter and access it later on. We go to the Parameters and add a new one.

We go back to the Flows and create our first one. For this, we simply want to query our organization’s repositories.

This is an easy task because we already know the URL and the parameters for it. To query the repositories, we need to call https://api.github.com/orgs/loadmill/repos .

We want to be as flexible as possible with the organization’s name, so we swap it out like this by using our parameter’s name: https://api.github.com/orgs/${org}/repos

If we click on the Run button, you will notice that our test passes.

To validate our request, we expand the Advanced options and look into the ‘Verify Response’ section. In here, we can validate our response message with JSONPath. For testing purposes, we can validate the topmost repository with a JSONPath similar to this:

Here we simply store the repository canonical name as a new session parameter and validate it against our test bench below. We hit run again and see our test passing in all its glory.

(Oh, you can also inspect the request and response headers there)

Great, let’s move on. Now we want to query the topmost repository and see how that behaves. We have already stored the repository ID so there’s nothing else missing. We know that we can access it by requesting https://api.github.com/repos/loadmill/express-loadmill . A bit of transformation like https://api.github.com/repos/${org}/${repoId} puts it to the way we need it. Loadmill populates the parameters for us automatically.

Since we expect our API to return the same name of the repository, we can validate it against it in the Response Handling section.

Once we run the suite, we notice that the Flow passes without errors.

You have hopefully noticed that it’s easy to create these tests. There’s no reason that you should be afraid of doing it, nor are you wasting your or anyone’s time with it.

Feel free to play around and make sure to check out Loadmill’s docs for more information.

Happy testing.