Rails 3,有太多测试方法吗? [英] Rails 3, too many ways to test?

查看:55
本文介绍了Rails 3,有太多测试方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您只是刚开始,那会鼓励新用户放弃 Testing .

If you were just starting out in rails which path would you encourage new users to go down with regards to Testing.

关于Rails 3的所有内容,都告诉我应该使用 Rspec 2 .但是Rspec附带了我需要学习的其他东西

Anything I read about regarding Rails 3, tells me I should be using Rspec 2. But Rspec comes with a whole whack of other things I need to learn like

gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'cucumber'
gem 'spork'
gem 'launchy'

然后我的一个朋友告诉我,我应该坚持使用Rails附带的测试框架,也许只是将"shoulda"集成到测试过程中,因为它具有很好的语法.

And then one of my friends just told me that I should just stick to the testing framework that comes with rails, and maybe just integrate 'shoulda' into the test process because it has a nice syntax.

当涉及到测试时,我们似乎有太多的选择余地,并且有太多的做事方式.也许这是一件好事,但是我一直认为rails是关于创建通用约定并避免以不同的方式做同样的事情.

When it comes to testing it seems like we have way too many options and too many ways of doing something. Maybe this is a good thing, but I always thought rails was about creating common conventions and avoiding doing the same thing in different ways.

我刚接触Rails.
我不确定从哪里开始.
我不知所措.
这正常吗?

I'm fairly new to rails.
I'm unsure where to start.
I feel overwhelmed.
Is this normal?

推荐答案

由于您是从Rails开始的,所以我建议您使用可以正常使用"的东西来养成测试代码和理解如何工作的习惯与您的框架.不要浪费时间比较解决方案,选择一个并坚持该项目.

Since you're beginning with rails, I'd recommend using something that "just works" to get in the habit of testing your code and understanding how to work with your framework. Don't waste your time comparing solutions, choose one and stick with it for this project.

话虽如此,我真的认为这取决于您开发软件的经验:

That being said, I really think it depends on your experience developing software:

  • 如果您从未使用过代码的单元测试,请学习Test :: Unit并考虑采用TDD.请注意,TDD首先需要您投入大量时间,但是当您习惯了它时,这是有回报的.
  • 如果您具有丰富的代码测试经验,并且对如何使用Rails感到困惑,建议您通过 http://railstutorial.org/book .这是一本(免费的)Ruby on Rails书籍,其中使用了RSpec,Spork,并作为一个很好的介绍
  • if you've never used unit tests for your code, learn Test::Unit and consider adopting TDD. Notice that TDD will need you to dedicate a large amount of time to it at first, but that is paid off when you get used to it.
  • if you have significant experience with code tests and are just confused on how to start with rails, I recommend following through http://railstutorial.org/book. This is a (free) Ruby on Rails book that uses RSpec, Spork and serves as a great introduction

使用现在选择的测试平台从头到尾开发一个项目后,您将有一个更好更好的任务来选择想要使用的测试框架.

After developing one project from start to end using the testing platform you choose now, you'll have a much better task of choosing the testing framework you wish to use.

我还建议您在深入黄瓜之前先学习RSpec.

I'd also recommend you learn RSpec well before diving into Cucumber.

这篇关于Rails 3,有太多测试方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆