Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Track down what's causing slow rspec tests

The specs for my rails project have been really slow lately. I did a git bisect to see if I could determine what has been slowing it and I found that certain commits that were previously running just fine are now just as slow as the current HEAD.

This leads me to believe that my problem is being caused by a gem updating or something else that's not under my source control. The problem still occurs on other dev machines so I don't think it's my personal environment either.

What's the best way to track down my slowest tests and then figure out what's slowing them down so much?

like image 265
Christian Schlensker Avatar asked Jan 23 '12 22:01

Christian Schlensker


People also ask

How to speed up RSpec tests?

Parallel testing You can try to speed them up by adding the parallel_tests gem . It sets up your test environment by running test in multiple threads or CPUs. It allows you to split tests into groups and run in a single process with its own database.

Does RSpec run in parallel?

Run RSpec Tests in ParallelOn BrowserStack, you can run multiple RSpec tests at the same time across various browser, device, and OS combinations.

What does RSpec describe do?

The word describe is an RSpec keyword. It is used to define an “Example Group”. You can think of an “Example Group” as a collection of tests. The describe keyword can take a class name and/or string argument.

How does RSpec work in Rails?

RSpec is a testing tool for Ruby, created for behavior-driven development (BDD). It is the most frequently used testing library for Ruby in production applications. Even though it has a very rich and powerful DSL (domain-specific language), at its core it is a simple tool which you can start using rather quickly.


1 Answers

This flag will tell you which tests are the bottlenecks:

$ rspec --profile
like image 93
Gabe Kopley Avatar answered Oct 21 '22 03:10

Gabe Kopley