Chances are that a big reason your tests are so slow is all of those extra objects you are creating. Recently I cut down on the objects in my tests and I was able to speed up by cucumber runs by 30-40%. I achieved most of those gains by making some small changes to factory girl. I don't want to bore you with the detail of our object model but it goes something like this. Our main object is a space and our tests frequently create several of them. The problem is that a space has a reference to a user, property, an contacts. Each of those actually have references to other objects. Just by creating a few spaces we end up creating a web of objects but our tests didn't need all of these extra objects. Enter the default objects within our factory_girl definitions:
Instead of creating new properties, users, and contacts each time a space is created, by default all spaces share the same nested objects. Most often this is not at all a problem in any of our tests. If we do require spaces do not share the same property, we specify it the Given section of our test.
very nice! check out parallel_tests as well, works pretty nice for CI. needed some work for external services but i've seen some gains
ReplyDelete@ilya - I use parallel_tests as well. Everything helps :-).
ReplyDeleteLooking for more exciting and interesting gourmet recipes ... try to visit my favorite food site ... www.gourmetrecipe.com ... they have lots of recipes and cuisines for you to choose from! Not only that, they do have also recipe video for you to watch!
ReplyDelete