DEV Community

Graham Cox
Graham Cox

Posted on

2

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.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay