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... I''m using rails-test-serve but that only brings the test down to 15 seconds....thanks for any help!
jko170 wrote:> 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 - Looked into autotest - Buy better hardware - Tune the database -- Roderick van Domburg http://www.nedforce.com -- Posted via http://www.ruby-forum.com/.
On Wed, May 27, 2009 at 1:02 PM, jko170 <jko170-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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... > > I''m using rails-test-serve but that only brings the test down to 15 > seconds....thanks for any help!Try out the "Single Test" plugin ( http://agilewebdevelopment.com/plugins/single_test ) 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. -- Steven Hilton <mshiltonj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
jko170 wrote:> 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?> I''m using Machinist. How can I speed up my tests? It has really killed > my motivation to test at all...Can you still TDD by using rake test:recent? And how long does rake test:units take? -- Phlip
Phlip wrote:> jko170 wrote: > >> 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? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
On Wed, May 27, 2009 at 12:02 PM, jko170 <jko170-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > My app has 64 models and my test are so slow. 30 seconds at least.30 seconds isn''t bad at all.> I''m using Machinist. How can I speed up my tests? It has really killed > my motivation to test at all... > > I''m using rails-test-serve but that only brings the test down to 15 > seconds....thanks for any help!You might try moving your unit tests into memory. http://www.thoughtbot.com/projects/factory_girl/ -- Greg Donald http://destiney.com/
peter-GjYF4n1IEWgTLKFV+Hedng@public.gmane.org
2009-May-27 23:59 UTC
Re: slow tests on large rails app
The apps I work on at work have 180+ models each. There isn''t duplication, but just way too many features. :( What Greg said works pretty well for us - factory_girl or any of the other factory libraries are great. You could also mock the AR find/delete/create/update calls if you want and return objects afterwards. That''s helped me in some side projects. I wish my test suite would run in 30 seconds though! On May 27, 2:26 pm, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, May 27, 2009 at 12:02 PM, jko170 <jko...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > My app has 64 models and my test are so slow. 30 seconds at least. > > 30 seconds isn''t bad at all. > > > I''m using Machinist. How can I speed up my tests? It has really killed > > my motivation to test at all... > > > I''m using rails-test-serve but that only brings the test down to 15 > > seconds....thanks for any help! > > You might try moving your unit tests into memory. > > http://www.thoughtbot.com/projects/factory_girl/ > > -- > Greg Donaldhttp://destiney.com/
Greg Donald wrote:> > 30 seconds isn''t bad at all.True, but you probably wouldn''t want it to be any longer than that if you''re using autotest or similar. [...]> > You might try moving your unit tests into memory. > > http://www.thoughtbot.com/projects/factory_girl/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.> > > -- > Greg Donald > http://destiney.com/Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
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. Have you guys seen this? http://www.devver.net/ Hopefully this will help a problem which currently the only solution is running them in parallel.
So far, this is the fastest solution I can find: Dataset with rails-test-serving http://github.com/Roman2K/rails-test-serving http://github.com/aiwilliams/dataset 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.
> Factory''s are nice but they make your tests very slow.This has been my experience, too. I attempted to solve it (with some measure of success) with my factory_data_preloader gem: http://github.com/myronmarston/factory_data_preloader/tree/master You can also benchmark your tests to see where the bottlenecks are: http://github.com/myronmarston/test_benchmarker/tree/master
Check out this (my) presentation: http://bit.ly/grease-your-suite-html arrow keys navigate. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Myron Marston wrote:>> Factory''s are nice but they make your tests very slow. > > This has been my experience, too.Though not mine as far as I can tell. Which factory library are you using? I use Machinist. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.