Use Docker for integration testing

grahamcox82

Graham Cox

Posted on January 14, 2017

Use Docker for integration testing

Last time, I wrote up my method for running Docker from Grunt, reliably and cleanly.

In general, in Java I've never bothered with this. I've run my dependencies in session - either in process, if it's a Java app, or using something like Flapdoodle OSS if not. This works, mostly, and is generally very easy but isn't always best.

On the plus side, you need nothing special set up on your machine to run your builds and tests. You need Java, and your build tool, and that's it. You generally don't need to worry about port clashes either, as you either can run on a free port or without networking at all.

On the minus side though, you're not running the dependencies in a realistic way. This can be huge in some cases.

MySQL, for example, acts subtlety differently when the filesystem is case sensitive - Linux - from when it's not - Windows and Mac. It's not an obvious difference, but it's an important one.

I've also discovered that it's impossible to run neo4j and elasticsearch in the same JVM classloader - due to different versions of lucene needed.

Running your dependencies in Docker is not trivial by any means, but it does remove all of these problems. It also becomes possible to run the exact same Docker images for your dependencies all the way from Dev to Prod, which is huge.

💖 💪 🙅 🚩
grahamcox82
Graham Cox

Posted on January 14, 2017

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Use Docker for integration testing
100daysofcode Use Docker for integration testing

January 14, 2017