Thursday, May 2, 2019

Microservices Integration Tests With Hoverfly and Testcontainers

Building good integration tests of a system consisting of several microservices may be quite a challenge. Today I'm going to show you how to use such tools like Hoverfly and Testcontainers to implement such tests. I have already written about Hoverfly in my previous articles, as well as about Testcontainers. If you are interested in an intro to these framework you may take a look on the following articles:

Today we will consider the system consisting of three microservices, where each microservice is developed by a different team. One of these microservices trip-management is integrating with two others: driver-management and passenger-management. The question is how to organize integration tests under these assumptions. In that case we can use one of the interesting features provided by Hoverfly — the ability to run it as a remote proxy. What does it mean in practice? It is illustrated in the picture below. The same external instance of a Hoverfly proxy is shared between all microservices during JUnit tests. Thedriver-management and passenger-management microservices are testing their own methods exposed for use by trip-management, but all the requests are sent through a Hoverfly remote instance which acts as a proxy. Hoverfly will capture all the requests and responses sent during the tests. On the other hand, trip-management is also testing its methods, but the communication with other microservices is simulated by a remote Hoverfly instance based on previously captured HTTP traffic.



from DZone.com Feed http://bit.ly/2VBeoDU

No comments:

Post a Comment