Java_Magazine_NovemberDecember_2018

(singke) #1

08


Microservices continue to gain
ground in enterprises due to the
benefits for which they have been
most promoted: reduced size,
loose coupling, and the compos-
ability 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 micro­
services gain traction, however,
there has arisen the nettlesome
problem of testing them.
Testing Java Microservices aims
to provide a solution to this prob-
lem by examining a small ecosys-
tem 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 con-
sumer (how does it function when
used as a REST service?), and as a
client (by driving browser activ-
ity). 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 origi-
nally 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 test-
ing with familiar products, such as
JUnit and Mockito. In this sense,
the book serves as a reasonable
overview of testing micro services.
However, everything is still fun-
damentally 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 impor-
tant resource to know about. (The
authors do cover a similar resource,
Hoverfly, which is briefly intro-
duced and explained in the book.)
A final chapter covers the
crucial topic of setting up the
micro service 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 Micro­
services 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 pri-
mary microservices testing frame-
work. —Andrew Binstock

// java books/


TESTING JAVA MICROSERVICES
By Alex Bueno, Andy Gumbrecht, and Jason Porter
Free download pdf