rails测试之BDD--rspec--capybara

来源:互联网 发布:linux中移动文件夹 编辑:程序博客网 时间:2024/05/03 03:37

rails测试之BDD--rspec--capybara

一,Background

什么是bdd?干什么用的?

bdds 就是英文 Behavior-Driven Development,是用来做开发测试。

bdd和单元测试,交付测试什么关系?

At the heart of BDD is a rethinking of the approach to unit testing and acceptance testing that North came up with while dealing with these issues.(我翻译不是很理想,就把它copy给大家看看吧)

cucumber和rspec区别是什么?

We use Cucumber to describe the behaviour of applications and RSpec to describe the behaviour of objects

二,Begin to introduce

  开始介绍基本操作:

  1. 新建一个项目;
  2. 在你的gemfile.rb里面添加
    group :test do  gem 'capybara'  gem 'rspec-rails'end
  3. 执行 ‘bundle install’
  4. 执行‘rails g rspec:install’
    这时候就生成了spec文件夹和spec_helper.rb
  5. 在spec文件夹新建文件夹“requests”
    这个文件夹里面新建我们测试文件
  6. 把这个放到spec_helper.rb里面的config
    config.include Capybara::DSL


三,It's the staff(how to do it)


原创粉丝点击