Spring Advantages

Let's go through the advantages of Spring.

How useful all of this is depends on what we’re trying to do.

Essentially, Spring is useful to the extent that startup time is swamping our test runtime. This normally happens in one of the following cases:

  • Our test suite runtime is less than our application startup time

  • Our test suite is slow, but we’re willing to run just a small subset of our tests during much of our TDD development

  • Any port in a storm, because it can’t hurt to have a preloader.

We’ll pause at this point to mention that we use Spring as part of my regular test practice. Pre–4.1 Rails, we used a similar tool called Zeus. So whatever else we say in the rest of this section, we think that Spring is valuable in many cases. Especially when we are running a minimal subset of failing tests over and over, it can be a significant win.

Spring uses

Spring is, however, one of those tools that best help us when we’re already helping ourselves. If our test suite takes 20 minutes to run, we’re already sunk, and the 15 extra seconds to load Rails isn’t going to help much.

Hide problems

Spring can hide problems in a test suite by letting us run individual pieces of the suite much faster. It can reduce the pressure we might feel to speed up each test file. There’s a Spring “uncanny valley”: if an individual file takes 30 seconds, that’s both fast enough for Spring to feel like a win and slow enough for it to be a serious drain on the entire project suite as we continue to add up 30-second files. We don’t want to be there. It’ll feel like our suite isn’t getting any worse, but it is.

Fast TDD feedback

That said, if we’re already stuck in a bad situation because we inherited it (or for whatever reason), Spring can be great and can allow us to have fast TDD feedback on the new stuff we’re building without being tied to the poor decisions of the past. Just don’t keep making the same poor decisions.

Get hands-on with 1400+ tech skills courses.