Integration Testing with TestContainers
The road has been difficult for anyone who has attempted to do any database testing for the last 20 years. One solution that we tried was installing the test database. Oftentimes, that has been hard to maintain, particularly when that test database is shared. Another solution is to use DBUnit on a local system or, possibly, a shared system to set up the database as needed, test it, and tear it down. That too, was very hard to maintain. For many, it was just deploying your application and running end-to-end tests. If it works, it works, and we move on. With the advent of containerization, we now have something substantially better, test containers! Test containers give us the power to bring up a database that we need to test against and the exact version of the database.
With Test Containers, we can programmatically set the required database, possibly insert some data, and run our test against it. Behind the scene, test containers will load and cache the database so we may run the database subsequently and even faster. There are a multitude of databases to choose from, and it is also supported by multiple languages like Java, Go, Ruby, and more.
About Daniel Hinojosa
Daniel is a programmer, consultant, instructor, speaker, and recent author. With over 20 years of experience, he does work for private, educational, and government institutions. He is also currently a speaker for No Fluff Just Stuff tour. Daniel loves JVM languages like Java, Groovy, and Scala; but also dabbles with non JVM languages like Haskell, Ruby, Python, LISP, C, C++. He is an avid Pomodoro Technique Practitioner and makes every attempt to learn a new programming language every year. For downtime, he enjoys reading, swimming, Legos, football, and barbecuing.
More About Daniel »