Testing Data Layers with TestContainers

Categories: Testing, Integration Testing, TestContainers

In the past, testing the data layer was hard, really hard. It would include a test database, as opposed to the production which of course we didn’t want to use for testing. Maintaining any sort of consistency was a pain to do, and perhaps fell by the wayside because it was too tedious and too fragile. Then we used in-memory databases, but the only viable ones were HSQLDB or H2. The problem there though is that the SQL for the in-memory databases didn’t quite match up. Today we have Test Containers which uses a Docker Client to download a specific version of whatever database or messaging system you wish to integrate. The best part, you can test against the same version of the database or messaging system so you have higher confidence that your tests work.


In this presentation we will cover the following:

  • Using TestContainers with your favorite build tool.

  • Creating Effective Integration Tests

  • Discuss performing Integration Test Driven Development

  • How do you perform Unit Testing derived from the Integration Test

  • How do you maintain versioning?

  • How to set it up within Continuous Integration and Continuous Delivery