Testing with rake is REALLY time consuming! Every time I have to run a test, it eat up something like 4 to 6 seconds, only for start up O_O
There's nothing we can do to speed up? Perhaps something like spork?
Testing with rake is REALLY time consuming! Every time I have to run a test, it eat up something like 4 to 6 seconds, only for start up O_O
There's nothing we can do to speed up? Perhaps something like spork?
Use either spark or parallel_tests
Dheeraj Kumar
Hello Salvatore,
I think using things like spork or the like is just a band-aid and they are not a solution to the real problem which is the design and mixing things all together in rails provided and known things, specially controllers and models. If we have good design with Single Responsibility Principle and Separation of Concerns we can have incredibly fast tests with focused pieces in our design. And we only need rake or those stuff for running our rails-specific tests (like controller tests, model tests, etc.) and those tests wont need to be run as frequently as domain-logic tests. domain-logic tests should be run so frequently during the red-green-refactor cycle all the time and we should benefit from the quick feedback and other things which are provided by having fast tests.
I recommend you to watch this interesting talk by Corey Haines -> http://arrrrcamp.be/videos/2011/corey-haines---fast-rails-tests/ it'll be great explanation of the things I've just mentioned with perfect details and examples.
Hope that helps. Best Regards
Oh just stop it. Bending your app into a pretzel to get faster tests is the “band-aid”. Tools like Spork address a single issue - “environment reloading is expensive” - with a simple solution, not reloading when it isn’t needed. That’s far more useful, especially if you’re a developer on an existing app and don’t have the luxury of rewriting everything into Object-Oriented Nirvana.
–Matt Jones
Oh just stop it. Bending your app into a pretzel to get faster tests is the “band-aid”.
Really? it’s not about bending app into pretzel, it’s about designing the app in a way that each part has only one reason to change. and not making things depend on stuff
that they don’t have anything to do with them. I think shoving lots of things into models and controllers is not a good idea and we’ll end up with God classes and modules which
will change for lots of different reasons.
BTW it’s not for getting fast tests. in TDD when it’s hard to write tests or the tests are slow when they should not (when they don’t need rails for instance) they’re shouting
about the problems in the design it’s like an alarm. And we should pay attention to this quick feedback and do something about it otherwise it’ll get worse and worse.
Tools like Spork address a single issue - “environment reloading is expensive” - with a simple solution, not reloading when it isn’t needed. That’s far more useful, especially if you’re a developer on an existing app and don’t have the luxury of rewriting everything into Object-Oriented Nirvana.
I completely agree with you that not loading things when they are not needed is a great solution. and if you think about it this whole design idea for putting things where they belong
and not in models and controllers is doing this too. You’re not depending a logic to ActiveRecord or ApplicationController ergo, you’re not loading things that you don’t need at the moment
and you don’t depend upon things that you don’t have too. Of course doing this is harder in an existing application but trying to improve the design toward this style in small steps and using
the existing SLOW tests to make sure we’re not breaking things is a good thing to do. Until we end up with a great design with extracted domain-logic modules in their own place and having incredibly
fast isolated tests for them. (That’s my idea and probably I’m wrong though ;):D)
Good Luck
Best Regards
I agree with doing fast, isolated test and follow the single responsibility principle, however my problem with rake & rails is not the execution time of tests, but the start up of rake instead. I'm trying to use Test Driven Design, so I run test a lot and it's a pain if every time I lost 6+ seconds for ONLY rake test start up; inadmissible. I think culprit is not rake itself, but start up of rails' environment. Now, I've found the spork-testunit gem, not user-friendly as "rake test", but a lot more faster and test execute in a blink of eyes: 0.5 sec VS 7 sec. For me, that's the solution.