Getting Started with Running Smaller Groups of Tests

Let's get started with how we can run smaller groups of tests very fast.

We'll cover the following

In this course, we’ve talked about how important rapid feedback is to fully benefit the TDD process. We can make our TDD feedback happen faster in several ways. We can run a focused subset of our test suite so that we see only the tests relating to the code we’re working on. We can have tests run automatically when the code changes. We can make the loading of the Rails application happen in the background or bypass Rails altogether. And, of course, we can avoid doing prolonged things.

Let’s look at the many ways to speed up tests.

Running smaller groups of tests

Running just some of our tests at once is often useful. Running a relevant subset of tests will let us get most of the value of rapid testing feedback without the entire test suite’s cost if we have a slow test suite. When debugging, we often care about one or two tests. Also, if we’re verbose about printing output to the terminal, then only running one test will spare us from potentially having to wade through a lot of spurious output. If we’re running Pry, only running one test will let us focus better.

Note: If we have a slow test suite, we can mitigate the effects in practice by running a relevant subset of tests.

Each tool has its own way of running one file or one set of tests at once.

Get hands-on with 1200+ tech skills courses.