JDK IO 2017 - Asaf Mesika - Microservices Testing In the Docker Era

Опубликовано: 25 Февраль 2025
на канале: Christian Damsgaard
99
0

"To mock or not to mock" that is the question which has been dividing the developer community for quite a while. The discussion climaxed after the heated debate between DHH, Kent Beck and Martin Fowler - “Is TDD Dead?”. The developers siding with mocks do it primarily due to the difficulty of launching third party components. Some are written in Java - like Kafka or Elasticsearch - which makes it easier to use the real thing - but some are not, which leaves you only with binaries, like MySQL, Redis or Consul. Launching binaries using the shell from Java, being platform agnostic, and taking care of downloading the correct platform binary are just some of the difficulties developers are facing.

In this lecture I will show how the existence of Docker transforms the way tests are written. I will introduce you to the innovative library Testcontainers, which provides a complete toolset for controlling Docker in tests. For example, we will take a look at how it enables starting up Consul or MySQL using three lines of code. We will review what the Testing Dichotomy looks like with this power in your hands. At the end of this lecture the audience will know how to test in a pragmatic way making it productively as a result. I believe this approach is mandatory as the world shifts heavily towards team autonomy which means automating your tests on your own - i.e. No QA team dependency.