如何和如何测试通过使用分别使用Cucumber和Rspec? [英] How and what to test by using respectively Cucumber and Rspec?

查看:302
本文介绍了如何和如何测试通过使用分别使用Cucumber和Rspec?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ruby on Rails 3.2.2,cucumber-rails-1.3.0,rspec-rails-2.8.1和capybara-1.1.2与Selenium驱动程序。我想分别使用Cucumber和Rspec来了解如何和如何进行测试?也就是说,应该使用Cucumber处理什么行为 Rspec如何以正确的方式分割测试关注点?



为了测试视图,使用Cucumber或RSpec测试页面内容中是否存在CSS id ?或者两者?

解决方案

使用RSpec通过隔离应用程序的各个部分(控制器,模型和视图) (使用Mock,Stub和其他为您提供RSpec的工具)



使用Cucumber测试应用程序的所有部分,就像在浏览器中看到的应用程序一样。例如,如果你需要测试没有黄瓜的应用程序的登录形式,你应该:



1)打开shell并运行rails服务器。



2)转到浏览器并键入登录网址。



3)填写表单字段。 / p>

4)点击提交按钮。



你应该自动化这个过程,类似的过程用Cucumber,使用Rspec。


I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2 with the Selenium driver. I would like to know how and what to test by using respectively Cucumber and Rspec? That is, what "behavior" should I treat with Cucumber and what with Rspec so to divide testing "concerns" in a proper way?

For example, in order to test a view, should I test the presence of a CSS id in a page content by using Cucumber or RSpec? or both?

解决方案

Use RSpec to test the various parts(Controllers, Models and Views) of your app by isolating them. (with Mock, Stub and the others tools that gives you RSpec)

Use Cucumber to test all parts of your app togheter, as you see the app in the browser... for example, if you need to test the sign in form of your app without cucumber you should:

1) Open a shell and run rails server.

2) Go to browser and type the url of login.

3) Fill in form fields.

4) Click Submit button.

You should automate this process, and similar process with Cucumber, for others test use Rspec.

这篇关于如何和如何测试通过使用分别使用Cucumber和Rspec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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