DEV Community


Use Docker for integration testing

grahamcox82 profile image Graham Cox ・1 min read

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.

Discussion (0)

Forem Open with the Forem app