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
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.
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.
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.