[LRUG] Large Slow Test Suites

James McCarthy james2mccarthy at gmail.com
Wed Dec 4 15:00:20 PST 2013


I'd try it with no internets and catch any stupid test touching api's, then look at factories, 

if it's using factory girl you've got some opportunities http://robots.thoughtbot.com/use-factory-girls-build-stubbed-for-a-faster-test 

If it's using devise, reduce the stretch in your test helper; Devise.stretches = 1

Where is the most time going to model, controller or integration? Is it disproportionate?

J.

Sent from my iPad

> On 4 Dec 2013, at 17:43, Jon Leighton <j at jonathanleighton.com> wrote:
> 
> Hello there,
> 
>> On 04/12/13 22:20, Mr Jaba wrote:
>> I've recently taken ownership of a new project with a large test suite
>> (2000ish tests), and the overall run time is around 30 minutes which is
>> certainly less than ideal! 
>> 
>> Now I know the general approach to "Fast Rails Tests" but taking the
>> time to refactor the whole test suite is a bit too much right now. I'm
>> wondering if anyone has experience of transforming a test suite of this
>> magnitude to something a bit speedier? If so how did you go about it?
>> What tips, tricks and techniques can you share? 
>> 
>> A bit more info:
>> 
>> - Test::Unit tests, moving to Minitest
>> - Rails 3.2.16
>> - Running parallel_tests shaved 5 mins off the time
>> - Using Spring to reduce Rails load time. 
>> 
>> Any advice gratefully received!
> 
> I think you need to provide some more information :) What's making it
> take so long - the sheer number of tests or what the tests are doing? Do
> you have certain types of tests that are taking a large portion of the
> time (e.g. Capybara tests?) Are you using factories? In my experience
> factories are an easy cause of a slow test suite.
> 
> One thing to think about is whether you can break up your test suite.
> For example in the application I work on, we have unit/integration tests
> which run in about 25 seconds on my machine. I frequently run these
> during development and they often alert me to problems. But I rarely run
> the full set of capybara tests which takes several minutes - I let the
> CI do that and run failing tests individually where necessary. This
> achieves a decent balance of fast feedback for development without
> throwing away the safety net of proper full-stack tests.
> 
> Jon
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20131204/391576e8/attachment.html>


More information about the Chat mailing list