I am new to BDD. Every time I try using cucumber, I find it pretty slow. I have tried with Rails 3.0.9 & 3.1 on two different machines. One of machines is an old IBM thinkpad laptop with 2 GB ram; and the other one is a PC with 4 GB RAM [I can get exact specifications if required]. Both run Fedora 14.
Even with a new application with no scnerios Cucumber take minutes. Here is how it goes:
$ cucumber
Using the default profile...
--- about 2 minutes delay---- and then it says:
0 scenarios
0 steps
0m0.000s
In contrast, Rspec is instant:
rspec
No examples found.
Finished in 0.00005 seconds
0 examples, 0 failures
While cucumber says it took 0m0.000s ; it has taken about 2 minutes in reality. And, RSpec was instant and shows the time correctly as well: 0.00005 seconds.
Is this normal. Do I need some additional Gems Or settings to make the process faster.
Update: Here is more data:
First with cucumber:
$time cucumber
Using the default profile...
0 scenarios
0 steps
0m0.000s
real 0m53.489s
user 0m37.051s
sys 0m1.973s
and then with rspec
$ time rspec spec/
No examples found.
Finished in 0.00005 seconds
0 examples, 0 failures
real 0m1.925s
user 0m1.032s
sys 0m0.155s
You're blaming the slowness on the wrong tool. What's slow is Ruby and Rails' startup time, not Cucumber. This is well known.
Ok. Used Spork, and here is the data again:
Rspec is faster then earlier even with no examples, I can feel the difference:
$ time rspec --drb spec/
Finished in 0.00182 seconds
0 examples, 0 failures
real 0m1.495s
user 0m0.952s
sys 0m0.147s
And Here is the data for Cucumber:
... suspense....
$ time cucumber --drb
Using the default profile...
Disabling profiles...
0 scenarios
0 steps
0m0.000s
real 0m3.775s
user 0m2.187s
sys 0m0.367s
Wow, there is marked difference now. If you get "undefined method `World' for main:Object (NoMethodError)" Please use spork version 0.9.0.rc9.
Update: Here are the steps, if someone else needs them [Ruby 1.9.2 + Rails 3.1]:
Gemfile:
group :development do
gem 'rspec-rails'
end
group :test do
gem 'database_cleaner'
gem 'rails3-generators'
gem 'factory_girl_rails'
gem 'cucumber-rails'
gem 'capybara'
gem 'spork', '0.9.0.rc9'
end
Then, run bundle install:
bundle install
[If you are using rspec]
rails g rspec:install
spork --bootstrap
edit spec/spec_helper.rb and follow instructions. Basically put everything between
Spork.prefork do
end
for cucumber:
rails g cucumber:install --spork
Run spork
bundle exec spork cuc
Run tests:
rspec --drb spec/
cucumber --drb
Enjoy BDD!! Autotest next!
Update:
You can add --drb to .rspec to run rspec without the --drb option.
Update:
Just realized I don't need --drb with cucumber.. with a spork server running, following would be sufficient:
cucumber features/
You're not the only one, I stopped using cucumber because it just took too long on my computer. My RSpec is a little bit slow only if I get a lot of examples (70-100ish) compared to the Rails-casts and other peoples tutorials I've watched but to me its fine(10-12 sec). Cucumber took the same amount of time on mine, my specs are:
Windows 7 64bit
Intel i3 3.19 Ghz
4.00 Gb Ram
And it still drags ass, it's annoying that I have to upgrade my computer just to get this to run fast! It a could be Windows 7 thing.
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