开发者

Can rails test speed be increased?

I'm a recent convert to TDD but as my codebase grows i开发者_Python百科n size and complexity, I find myself waiting longer and longer periods for the framework to load every time I want to run a test.

I am aware of rspec's spec_server but I'm using Test::Unit with shoulda. I tried Snailgun (http://github.com/candlerb/snailgun) but noticed very little increased in speed. I have also tried spork-testunit (http://github.com/timcharper/spork-testunit) but it's not fully compatible with my existing tests.

The delay in running tests is a definite pain point and is putting me off TDD (at least with Rails). Is anyone aware of any other options?


Are you using mocks where you need to?

You don't mention a mocking framework. Are you using one? Or are your tests large and do they test things like logging into web servers or running database queries?

I've heard a rule of thumb that unit tests should run about 100 per second, which precludes connecting to and using actual resources. Tests that access actual resources tend to be thought of as integration tests and they are understood to run slower than unit tests.


You could configure database.yml to use an in-memory SQLite3 database for tests.


Try autotest. It watches your files and runs them in the background. By the time you are done with an edit, it has already finished testing for you to review.

gem install autotest-rails
autotest

https://rubygems.org/gems/autotest-rails

http://ph7spot.com/musings/getting-started-with-autotest

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜