My app has 64 models and my test are so slow. 30 seconds at least.
I’m using Machinist. How can I speed up my tests? It has really killed
my motivation to test at all…
30 seconds? I’ll take that any day!
I am involved in one project that has a test suite which takes 24
minutes today and is ever expanding. The only option to improve the
speed of that is to do some sort of distributed building. We’re looking
at our options in that area.
Things we’ve done before:
Cut down the number of superfluous tests
Ensure your fixtures are transactional
Switch to Ruby Enterprise Edition or JRuby for faster execution
It allows you run the test of a single test file, or a single test
method, in isolation. This lets you focus on getting your one test or
or test file to work in a rapid-feedback way, and after your code
works and your tests pass, you run the full test suite before
committing to see if you broke anything elsewhere in the code base.
My app has 64 models and my test are so slow. 30 seconds at least.
Projects should not require so many models. Does your design have any
duplication?
That’s a lot of models, but I wonder if that’s the problem. I’m having
a problem with extremely slow specs on my app – only about 6
ActiveRecord models, but in my case I narrowed it down to the view
specs. I’m trying to use assert_select/have_tag and regexps to check
for the presence of certain content in the output. It works perfectly,
but takes forever. Any suggestions?
He already said he was using Machinist, so recommending Factory Girl is
probably not all that relevant, since it basically does the same thing
IIRC.
And was that meant to have anything to do with the suggestion of moving
stuff into memory? If so, what? My understanding is that both
Machinist and Factory Girl typically use the DB.
I was able to cut down a test file from 15 seconds to 2 seconds using
dataset’s “create_record” method, which bypasses validations.
Factory’s are nice but they make your tests very slow.
Hey guys, thanks for all the suggestions! Sorry, I meant 30 seconds each test file, not the entire suite. Whenever I run ‘rake’, I
always switch over and do something else for awhile because it takes
so long.