This post by Chaitali Narla and Diego Salas on the Google Testing blog introduces the concept of hermetic servers in software testing. In a situation where the System Under Test (SUT) is composed of multiple servers, the notion of hermetic servers will help to solve the challenges of writing a fast and reliable end-to-end tests, avoiding network access. The hermetic server could be defined as a “server in a box”. Thus your testing could all be started on a single machine, physical or virtual, without the need for a network connection.
The blog gives the following recommendations to build hermetic servers:
* All connections to other servers are injected into the server at runtime using some dependency injection like Guice.
* All required static files are bundled in the server binary.
* If the server talks to a datastore, it should be faked with data files or in-memory implementations.
* Make sure that connection points that shouldn’t be concerned have appropriate fakes or mocks to verify this non-interaction.
* Provide modules to easily populate datastores with test data.
* Provide logging modules to trace the request/response path as it passes through the SUT.
The conclusion of the post is that hermetic servers have some limitations but are a great testing tool. Like all other tools, they need to be used thoughtfully where appropriate.