我是BDD的新手。每当我尝试使用黄瓜时,我发现它很慢。我试过Rails 3.0.9& 3.1在两台不同的机器上。其中一台机器是旧的IBM thinkpad笔记本电脑,配备2 GB内存;另一个是带4 GB RAM的PC [如果需要,我可以得到确切的规格]。两者都运行Fedora 14。
即使使用没有scnerios的新应用程序,Cucumber也需要几分钟。这是怎么回事:
$ cucumber
Using the default profile...
--- about 2 minutes delay---- and then it says:
0 scenarios
0 steps
0m0.000s
相比之下,Rspec是即时的:
rspec
No examples found.
Finished in 0.00005 seconds
0 examples, 0 failures
虽然黄瓜说它需要0m0.000s;它实际上花了大约2分钟。并且,RSpec是即时的并且也正确显示时间:0.00005秒。
这是正常的吗?我是否需要一些额外的Gems或设置来加快处理速度。
更新:以下是更多数据:
首先是黄瓜:
$time cucumber
Using the default profile...
0 scenarios
0 steps
0m0.000s
real 0m53.489s
user 0m37.051s
sys 0m1.973s
然后使用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
答案 0 :(得分:8)
确定。使用Spork,这里又是数据:
即使没有例子,Rspec比之前更快,我能感觉到差异:
$ time rspec --drb spec/
Finished in 0.00182 seconds
0 examples, 0 failures
real 0m1.495s
user 0m0.952s
sys 0m0.147s
以下是黄瓜的数据:
...悬念....
$ time cucumber --drb
Using the default profile...
Disabling profiles...
0 scenarios
0 steps
0m0.000s
real 0m3.775s
user 0m2.187s
sys 0m0.367s
哇,现在有明显的区别。如果你得到main的未定义方法`World':Object(NoMethodError)“请使用spork版本0.9.0.rc9。
更新:以下是步骤,如果其他人需要它们[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
然后,运行bundle install:
bundle install
[如果您使用的是rspec]
rails g rspec:install
spork --bootstrap
编辑spec / spec_helper.rb并按照说明操作。基本上把所有东西都放在
之间Spork.prefork do
end
黄瓜:
rails g cucumber:install --spork
运行spork
bundle exec spork cuc
运行测试:
rspec --drb spec/
cucumber --drb
享受BDD !!自动测试下一个!
更新
您可以将.drb添加到.rspec以运行rspec而不使用--drb选项。
更新
刚刚意识到我不需要--drb with cucumber ..运行spork服务器,以下就足够了:
cucumber features/
答案 1 :(得分:1)
你不是唯一一个,我停止使用黄瓜,因为它在我的电脑上花了太长时间。我的RSpec有点慢,只有我得到了很多例子(70-100ish),而Rails-casts和我看过的其他人的教程,但对我来说很好(10-12秒)。黄瓜花了相同的时间,我的规格是:
Windows 7 64bit
Intel i3 3.19 Ghz
4.00 Gb Ram
它仍然拖着屁股,令人讨厌的是我必须升级我的电脑才能让它快速运行!它可能是Windows 7的东西。
答案 2 :(得分:1)
你责怪错误工具的缓慢。什么是缓慢的Ruby和Rails的启动时间,而不是Cucumber。这是众所周知的。