Being able to automatically test each microservice in isolation is, of course, very useful, but insufficient!
We need a way to automatically test all of our microservices to ensure that they deliver what we expect!
For this reason, I have written a simple bash script that can perform calls to a RESTful API using curl and verify its return code and parts of its JSON response using jq. The script contains two helper functions, assertCurl() and assertEqual(), to make the test code compact and easier to read.
For example, making a normal request and expecting 200 as the status code, as well as asserting that we get back a JSON response that returns the requested productId along with three recommendations and three reviews, looks like the following:
# Verify that a normal request works, expect three recommendations...