Itamar Turner-Trauring

10× faster database tests with Docker  ↦

Testing code that talks to the database can be slow. Fakes are fast but unrealistic. What to do? With a little help from Docker, you can write tests that run fast, use the real database, are easy to write and run.

I tried Itamar’s technique on’s test suite and the 679 tests complete in ~17 seconds. The same tests run directly against Postgres complete in ~12 seconds.

A net loss for me, but that may have something to do with how Docker for Mac works? I’d love to hear other people’s experiences.


Sign in or Join to comment or subscribe

2019-02-27T16:52:17Z ago

Apparently Docker for Mac does add a lot of filesystem I/O overhead, yeah.

The solution might be RAM disk, but the tmpfs method won’t work on Mac. You can use native Mac RAM disks, though, as documented here:

Can you try that and see if it speeds thing up?

0:00 / 0:00