Testcontainers for Real Integration Tests

A presentation at SwanseaCon in in Swansea, UK by Philipp Krenn

How are you doing integration tests with your datastore?

  • Mocking is not an option since you want to test the actual system.
  • There are some in-memory implementations, like H2 or HSQLDB for relational databases, but there are still subtle differences to your production system and not all datastores have in-memory cousins.
  • Using the actual datastore in your tests is possible, but managing it, running tests in parallel,... is far from ideal.

So what is the solution? There is a very neat solution based on containers: Testcontainers. From your tests you can start a lightweight, throwaway instance of your datastore and this talk will walk you through a practical example with Elasticsearch's Testcontainer after covering the issues of other approaches first. We are also discussing the general approach of Testcontainers and how they are now widely available for various datastores.

Resources

The following resources were mentioned during the presentation or are useful additional information.

  • GitHub: Demo Code

    Demoing multiple approaches of integration tests with Elasticsearch