behavior driven development cucumber · behavior driven development. feature: cucumber in order to...

44
Cucumber http://flickr.com/photos/nickatkins/527421404/ Brandon Keepers Collective idea http://opensoul.org with Behavior Driven Development

Upload: others

Post on 24-Jul-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Cucumber

http://flickr.com/photos/nickatkins/527421404/

Brandon Keepers ● Collective idea ● http://opensoul.org

withBehavior Driven Development

Page 2: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with Cucumber

Scenario: Behavior Driven Development with Cucumber Given a desire for higher quality software And a tool that executes feature documentation written in plain text When you watch this presentation Then you will gain an understanding of behavior driven development And see examples of behavior driven development with cucumber And be equipped to integrate Cucumber into your development process

Page 3: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Quality

Page 4: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

1Qualitymeets requirements

Page 5: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Developer

Client

Language

Page 6: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Developer

Client

Stories

Page 7: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with
Page 8: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

In order to keep of track movies that I want to seeAs a NetFlix customerI can add movies to a queue

http://dannorth.net/whats-in-a-story

Page 9: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

In order to keep of track movies that I want to seeAs a NetFlix customerI can add movies to a queue

http://dannorth.net/whats-in-a-story

value proposition

Page 10: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

In order to keep of track movies that I want to seeAs a NetFlix customerI can add movies to a queue

http://dannorth.net/whats-in-a-story

role

Page 11: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

In order to keep of track movies that I want to seeAs a NetFlix customerI can add movies to a queue

http://dannorth.net/whats-in-a-story

feature

Page 12: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

2Qualityworks as expected

Page 13: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Test Driven

Page 14: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Behavior Driven

Page 15: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with
Page 16: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Verify

Page 17: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Confidence

Page 18: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Design

Page 19: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Behavior

Page 20: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Testing

Specifying

Page 21: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Cucumber

http://flickr.com/photos/nickatkins/527421404/

Page 22: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

rbehave

rSpec Story Runner

Cucumber

Page 23: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

http://github.com/aslakhellesoy/cucumber

Page 24: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

$ gem install cucumber

Page 25: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

require 'rubygems'require 'cucumber/rake/task' Cucumber::Rake::Task.new

Rakefile

Page 26: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

$ rake features

Page 27: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Rails

$ ruby script/plugin install \git://github.com/aslakhellesoy/cucumber.git \git://github.com/brynary/webrat.git \git://github.com/dchelimsky/rspec.git \git://github.com/dchelimsky/rspec-rails.git

$ ruby script/plugin install \git://brandon.local/cucumber \git://brandon.local/webrat \git://brandon.local/rspec \git://brandon.local/rspec-rails

Page 28: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

$ gem install term-ansicolor \treetop diff-lcs hpricot

Dependencies

Page 29: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

$ ruby script/generate cucumber

Page 30: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Feature: Manage companies In order to keep track of companies A user Should be able to manage companies

Scenario: Create a new company Given I am logged in When I create a new company named Acme Then I should see that a company named Acme exists

Page 31: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

features/companies.featuresteps/company_steps.rb

Page 32: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Given "I am logged in" douser = Factory(:user)visits new_session_pathfills_in ‘Login’, :with => user.loginfills_in ‘Password’, :with => user.passwordclicks_button ‘Login’

end

Given == Setup

Page 33: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Given "I am logged in" douser = Factory(:user)visits new_session_pathfills_in ‘Login’, :with => user.loginfills_in ‘Password’, :with => user.passwordclicks_button ‘Login’

end

factory_girl

Factory.sequence(:email) {|n| "user#{n}@example.com" }Factory.define :user do |user| user.name 'User' user.email { Factory.next(:email) }user.login {|u| u.email }

user.password 'password' user.password_confirmation 'password'end

Page 34: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Given "I am logged in" douser = Factory(:user)visits new_session_pathfills_in 'Login', :with => user.loginfills_in 'Password', :with => user.passwordclicks_button 'Login'

end

webrat

Page 35: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

When "I create a new company named $name" do |name| visits new_company_path fills_in 'Name', :with => name clicks_button 'Create'end

When == Change

Page 36: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

When "I create a new company named $name" do |name| visits new_company_path fills_in 'Name', :with => name clicks_button 'Create'end

variable

When I create a new company named Acme

When == Change

Page 37: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Then "I should see that a company named $name exists" do |name| response.body.should =~ Regexp.new(name)end

Then == Outcome

Page 38: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Feature: Manage companies In order to keep track of companies A user Should be able to manage companies

Scenario: Create a new company Given I am logged in When I create a new company named Acme Then I should see that a company named Acme exists

3 steps passsed

Page 39: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Scenario: Paging through leads and rejecting Given a company called Apple Corp. And a company called Pear Inc. And a list for Client A And Apple Corp. is a new lead in a list for Client A And Pear Inc. is a new lead in a list for Client A And I am logged in as a staff member When I view the company overview for Apple Corp. And I reject Apple Corp. And I go to the next lead Then I see the company overview for Pear Inc.

Page 40: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Cucumber or RSpec?

Page 41: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Cucumber or RSpec?

BOTH

Page 42: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

http://github.com/bmabey/cucumber-tmbundle/

Page 43: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with Cucumber

Scenario: Behavior Driven Development with Cucumber Given a desire for higher quality software And a tool that executes feature documentation written in plain text When you watch this presentation Then you will gain an understanding of behavior driven development And see examples of behavior driven development with cucumber And be equipped to integrate Cucumber into your development process

6 steps passed

Page 44: Behavior Driven Development Cucumber · Behavior Driven Development. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with

@bkeepers

brandoncollectiveidea

github.com/

opensoul.orgsessions.collectiveidea.com