I'm using Ruby on Rails 3 and writing tests but it's too slow. Is there some good configure or tools to make that faster?
Probably the biggest speed gain comes from being careful not to hit the database unless you need to. Mock objects rather than fetch them from the database, and/or (if you are using factory girl for example) use Factory.build(:stuff) instead of Factory(:stuff) wherever possible. Only when you have done that should you start trying to optimise further with spork
Update: Personally, I'm also starting to think that you should not become to hung up about the speed of your tests anyway. Faster is obviously better, but as an application grows, the test suite will grow, and however careful you are it will eventually become slower than you would like. I'm coming to rely more and more on the autotest gem which tests changing code and works in the background (guard-rspec does a similar job). By the time your app reaches 1000 tests you will not want to wait for the whole suite to finish every time you make a change, however fast the tests run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With