The ultimate list of Testing Tools for Microservices
Microservices is a software architectural style that structures the application as a collection of services. This architectural style has several advantages over legacy software architectures. Applications based on the Microservices architecture are :
Componentised and Loosely coupled
Abstracted around business capabilities
Highly testable and maintainable.
The data interchange between the service and the browser is achieved using JSON objects. Microservices are usually implemented as RESTful API's that implement some or all of the HTTP verbs like GET, POST, PUT, PATCH and DELETE. RESTful API's are governed by standards like JSON-LD and Hydra to ensure that these API's can be discovered and consumed by devices like ATM's, POS machines etc. Teams engaged in developing microservice API's use a variety of tools to query the API. Some of these are GUI based while others are accessible from the command line. In this article we will examine the various tools by accessing a simple API that returns a list of "financial statements" in JSON LD format. We will specify the parameters and headers in our HTTP request. This will allow us to examine the pro's and cons of these tools.
Postman is available as a web service, as a plugin for a browser and as an application that can be installed for most operating systems. The GUI is pretty straight forward and specifying parameters is easy. However Postman adds its own headers to the request, at least the web service version I used for this article did. Postman allows the user to create workspaces to separate the application tests. Here is a screenshot of the request and response for a JSON/LD GET request. However to run Postman on the command line we will need to install Newman a NodeJS based runner.
I used to be amused by its initial avatar, it was called Postwoman before the name change. Hoppscotch like Postman offers a web based client. The GUI is pretty straight forward and specifying parameters is easy. Infact the URL takes you directly to the Hoppscotch client rather than a landing page. Unlike Postman, Hoppscotch doesn’t include any headers in the payload it sends to the API. It offers the HoppCLI NodeJS based runner to run collections on the command line.
Httpie is available for the web, desktop and for the terminal. As of this writing the web and desktop are in private beta release and not available to the general public. So I tested the CLI version on my Ubuntu laptop. Installation is from the apt repositories. Once installed it is available for use right away. Httpie adds a few headers to the request but can be overridden at the command line. For example it adds the “Accept: */*” header which was overwritten in my GET request.
Client URL or popularly called cURL is a command line based tool that is used to transfer data between servers. It supports various protocols in addition to HTTP and HTTPS. Various scripting languages like Perl, PHP and Python offer cURL library functions that allow programmers to write test cases that can access cURL functionality. Since its used from within programs where the results of a cURL call are stored in a variable and parsed, the output is raw, not elegant in appearance (like in the first screenshot). To see an elegant output the results of the cURL call should be piped to “jq: that formats the JSON output so it is easier to read (like in the second screenshot).
Created by the GNU Project wget is popularly used to download files from the internet. It can also be used to test API’s by sending the appropriate headers. Like cURL the output is raw and has to be piped to “jq” to make it easier to read.
We tested these tools for a single HTTP verb, the GET. A comprehensive test for all HTTP verbs should conducted using each of these tools to arrive at an objective decision on which of these tools offers the best set of features. However a personal favorite of mine is cURL. This is because I use PHP in most of my projects and PHP offers a comprehensive cURL library that allows me to write PHPUnit tests. I can then run these tests in a Jenkins pipeline without any intervention. Regression tests are run on every code commit in the night automatically. This allows me to get rid of bloated testing teams. The delivery is continuous and of course there are tremendous savings in costs.