为 rubyonrails 编写测试
我是为 rspect、steeak、cucumber 等 rubyonrails 应用程序编写测试的新手。我如何开始或学习才能帮助我编写漂亮的代码?
你可以举一些简单的例子或者一些我可以从零开始理解的网址。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
http://railscasts.com/episodes/155-beginning-with-cucumber - 适合初学者的好播客
The RSpec Book - 也非常有用
这是一个很好的起点,然后 Google 会帮助你
http://railscasts.com/episodes/155-beginning-with-cucumber - a good podcast for beginner
The RSpec Book - also very useful
It's a good point to start and then Google help you
1) 首先阅读 rails 测试指南,以了解测试的感受。
2) 熟悉各种测试框架(Cucumber、rspec、testunit、steeak、minitest ),观看截屏视频 (railscasts、TeachMeToCode),然后尝试选择一个对您有吸引力的。
3)编写测试!并在需要时从 StackOverflow 获取帮助。如果您喜欢 RSpec,那么 RSpec 书 非常有帮助,但不是必需的。
我个人对框架的看法:
我一开始非常喜欢 Cucumber,但最终发现它非常冗长,而且我不喜欢使用它进行集成测试,然后使用 RSpec 进行单元和功能测试。我现在喜欢仅将 RSpec 与 Capybara 和 Shoulda 匹配器一起使用。 TestUnit 甚至可以比 RSpec 更简洁,但我个人认为 RSpec 是编写自记录代码和不过于冗长之间的折衷方案。
1) Start by reading the rails testing guide just to get a feel for testing.
2) Become familiar with the various testing frameworks (Cucumber, rspec, testunit, steak, minitest), watch screencasts (railscasts, TeachMeToCode) and then try and choose one that appeals to you.
3) Write tests!! and get help as you need it from StackOverflow. If you like RSpec then the RSpec book is very helpful, but not essential.
My personal opinion on frameworks:
I started out really liking cucumber but I eventually found it very verbose and I didn't like using it for my integration tests and then RSpec for my unit and functional tests. I now like using just RSpec with Capybara and Shoulda matchers. TestUnit can be even less verbose than RSpec but personally I find RSpec to be the happy medium between writing self documenting code and not being overly verbose.
几天前我刚刚开始使用 RSpec,这非常困难(实际上仍然如此)。您可以从railstutorial.org 开始。作者遵循TDD原则。更多信息请访问 RSpec 和 黄瓜 github 页面。请务必查看维基百科。
I've just started with RSpec a few days ago and it was pretty hard (it still is actually). You could start from railstutorial.org. The author follows the TDD principle. More info available at RSpec and Cucumber github page. Be sure to check out the wiki.