Microservices continue to gain ground in enterprises due to the benefits for which they have been most promoted: reduced size, loose coupling, and the composability they enable. IT managers have begun to understand that service-based computing is not the same as the service-oriented architecture (SOA) popular at the turn of the century. As microservices gain traction, however, there has arisen the nettlesome problem of testing them.
Testing Java Microservices aims to provide a solution to this problem by examining a small ecosystem of tools based on Arquillian. The latter is a container-agnostic testing framework designed to test services as a producer (does it work correctly internally?), as a consumer (how does it function when used as a REST service?), and as a client (by driving browser activity). The distinguishing element of Arquillian is the ability to run your microservices and then execute tests against them. It can drive unit tests and integration tests, and it understands containers, virtualization, and fundamental problems of a testing environment, such as using a separate classpath. (Note that Arquillian was originally a framework for testing apps running in a Java EE container. Its most recent versions have added Spring support and the ability to work with Docker containers.)
The authors, who are strongly connected to Arquillian, are at pains to include coverage of tools other than Arquillian. And they introduce some notable tools—in particular Pact, which is a family of test frameworks for verifying consumer-side contract testing. The authors also integrate testing with familiar products, such as JUnit and Mockito. In this sense, the book serves as a reasonable overview of testing microservices. However, everything is still fundamentally tied to Arquillian and its way of doing things. As a result, other useful tools such as mountebank, which provides over-the-wire test doubles, are not mentioned at all, even though mountebank would be an important resource to know about. (The authors do cover a similar resource, Hoverfly, which is briefly introduced and explained in the book.)
A final chapter covers the crucial topic of setting up the microservice tests to run in a continuous-delivery pipeline. This step is easy to overlook because of its complexity, leading the final delivered service to be tested only in isolation.
Overall, Testing Java Microservices is a good introduction to the issues of testing microservices that run on the JVM (they need not be written in Java as the title would imply). However, its greatest value is to organizations that are evaluating Arquillian or are already committed to its use as their primary microservices testing framework.