使用哪种测试方法?[轨道] [英] Which testing method to go with? [Rails]

查看:33
本文介绍了使用哪种测试方法?[轨道]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天要为一个客户开始一个新项目.

I am starting a new project for a client today.

我之前做过一些 Rails 项目,但从来没有为它们编写测试.我想从这个新项目开始改变这一点.我知道有几种测试工具,但我不知道应该使用哪种工具.

I have done some rails projects before but never bothered writing tests for them. I'd like to change that starting with this new project. I am aware there are several testing tools, but am a bit confused as to which I should be using.

我听说过 RSpec、Mocha、Webrat 和 Cucumber.请记住,我从未真正编写过任何常规测试,因此我对测试的总体了解非常有限.

I heard of RSpec, Mocha, Webrat, and Cucumber. Please keep in mind I never really wrote any regular tests, so my knowledge of testing in general is quite limited.

你建议我如何开始?

谢谢!

谢谢大家的回复!我发布了一个相关问题,将来查看此问题的人可能会感兴趣.您可以在这里找到.

Thank you for all the responses! I posted a related question that may interest those who view this question in the future. You can find it here.

推荐答案

我更喜欢结合使用 Rspec 和 Cucumber.我也更喜欢 Capybara 而不是 Webrat.

I prefer using Rspec and Cucumber in conjunction. I also prefer Capybara over Webrat.

Rspec 非常棒,因为它的 Rails 集成和结构.它在技术上是行为测试,但实际上它最终感觉像是单元测试.它还允许您使用描述"块以您喜欢的任何结构对规范"或 rspec 测试进行分组和定义.

Rspec is wonderful for it's rails integration and structure. It's technically behavior testing, but in practice it ends up feeling like unit testing. It also allows you to group and define "specs", or rspec tests, in any structure you like with 'describe' blocks.

Cucumber 级别更高.这就是您将用户故事转化为的内容.例如,您可能决定您的用户应该能够更改他们的密码,因此您将编写如下内容:

Cucumber is higher level. It is what you will translate your user stories into. For instance, you may decide that your users should be able to change their password, so you'll write something like this:

 Scenario: Change password
    Given I am logged in
    And I am on the change password page
    When I fill in "p4ssw0rd" for "old_password"
    And I fill in "newp4ssw0rd$$" for "new_password"
    Then my password should be "newp4ssw0rd$$"

如果您与 QA 部门合作,您可以向他们展示您的测试,他们会立即知道任何给定功能的状态以及该功能应该如何工作.此外,如果您有有进取心的测试人员,即使他们不是一般的程序员,他们也可以自己编写测试.

If you are working with a QA dept, you can show your tests to them, and they'll instantly know the status of any given feature, and how the feature is supposed to work. Additionally, if you have enterprising testers, they can write tests themselves, even if they are not programmers in general.

这篇关于使用哪种测试方法?[轨道]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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