SlideShare a Scribd company logo
Our Evolving
Development Framework
Cucumber...

• is not just about testing
• is more than integration testing
• is behaviour driven development
The TDD/BDD Way

• Red
• Green
• Refactor
The Cucumber Way
1. Describe behaviour in plain text
2. Write a step definition in Ruby
3. Run and watch it fail
4. Write code to make the step pass
5. Run again and see the step pass
6. Repeat 2-5 until green like a cuke
7. Repeat 1-6 until the money runs out
Cucumber Terminology
• Features
 • In order to business value,
 • As a role,
 • I want to feature
• Scenarios
 • Given, When, Then
• Step Definitions
Cucumber Setup

•   features directory

•   plain text .feature files

•   step_definitions folder

•   ruby steps files

•   support folder
Feature & Scenario Example
Step Definition Examples
The AMC Way
•   Use Cucumber with:
    •   Webrat (built-in support)
    •   Machinist (fixture replacement)
    •   Ian White’s Pickle (extends Cucumber)
    •   Profiles
    •   Tags
    •   Scenario Outlines
    •   Background
Webrat
• browser simulator
• used by Cucumber by default
• common action step definitions predefined
  using webrat (webrat_steps.rb):
  When I press “Log in”
  Then I should see “Login
  successful”
Machinist

• Fixture replacement
• Allows you to work with real objects:
  User.make
  User.make(:name => ‘Bob’)
Pickle (for objects)
• Uses Machinist, Factory Girl or ActiveRecord
• Provides step definitions for your
  convenience (pickle_steps.rb):
  Given a user exists
  Given a user exists with name:
  “Bob”
Pickle (for paths)

• Extends paths.rb:
  When I go to the users page
  When I go to the user’s
  articles page
Pickle (for email)

• Provides step definitions for your
  convenience (email_steps.rb):
  Given all emails have been
  delivered
  Then 1 email should be
  delivered to “bob@uncle.com”
No New Steps Required
 Scenario: delivering comment notification to one user
    Given a question exists
    And a user exists with name: “Bob”, email:
    “uncle@bob.com”
    When I go to the question's page
    When I fill in "comment[body]" with "My comment"
    And I check “Bob”
    And I press "Add Comment"
    Then 1 email should be delivered to
    “uncle@bob.com”
    And I should see “Comment notification was sent”
Cucumber Profiles

• defined in cucumber.yml
• our current profiles:
 • default
 • sphinx
 • selenium
Default Profile

• uses transactional fixtures (wraps each
  scenario in a database transaction)
• uses webrat
• excludes sphinx and selenium features
Sphinx Profile

• for testing features that use thinking-sphinx
• won’t work with transactional fixtures
• use database cleaner gem instead
• uses webrat
• specifies only sphinx features
Selenium Profile
• useful for testing javascript features
• won’t work with transactional fixtures
• use database cleaner gem instead
• uses selenium webrat configuration
• drives a real browser
• specifies only selenium features
Using Profiles

cucumber
cucumber -p sphinx
cucumber -p selenium
Cucumber Tags
• used to target features and scenarios
• used by profiles:
  cucumber -t sphinx

• use @wip for feature or scenario that you
  are currently working on:
  cucumber -t wip
Cucumber Tags

•   Add directly above
    Feature or Scenario
    keywords

•   Can have more than one
    (comma separated)
Scenario Outlines
Scenario Outlines

• Useful for DRYing up your scenarios when
  only data is changing

• Use Scenario      Outline instead of
  Scenario
Background
Background


• Add context for your scenarios in a single
  feature
And More...
• Some other Cucumber features:
 • Nested steps
 • Hooks
 • Multi-line step arguments
 • Spork and --drb
• Cucumber continues to grow!

More Related Content

PDF
Reacting to the Isomorphic Buzz
KEY
RESTful Api practices Rails 3
PDF
Padrino - the Godfather of Sinatra
KEY
CatalystX::SimpleLogin
PDF
Modern Functional Fluent ColdFusion REST Apis
PDF
Put a Button on It: Removing Barriers to Going Fast
PPTX
Building rest services using aspnetwebapi
PPTX
Test automation with Cucumber-JVM
Reacting to the Isomorphic Buzz
RESTful Api practices Rails 3
Padrino - the Godfather of Sinatra
CatalystX::SimpleLogin
Modern Functional Fluent ColdFusion REST Apis
Put a Button on It: Removing Barriers to Going Fast
Building rest services using aspnetwebapi
Test automation with Cucumber-JVM

What's hot (20)

PDF
Flexible UI Components for a Multi-Framework World
ZIP
URUG Ruby on Rails Workshop - Sesssion 5
PDF
PLAT-8 Spring Web Scripts and Spring Surf
PPTX
GIB2021 - Testing with Postman
PDF
SpringMVC
PDF
Modern javascript
PPTX
Web Application Frameworks (WAF)
PDF
Why use Go for web development?
KEY
Capybara-Webkit
PPTX
Hands on Gradle
PDF
PLAT-7 Spring Web Scripts and Spring Surf
PDF
Webcomponents are your frameworks best friend
PDF
Ember and SharePoint
PPSX
Behaviour driven development present
PDF
Stackup New Languages Talk: Ember is for Everybody
PPTX
Automating JavaScript testing with Jasmine and Perl
PPTX
Day 8 - jRuby
PDF
Azkaban-en
PDF
Gemboys
PDF
Frameworks and webcomponents
Flexible UI Components for a Multi-Framework World
URUG Ruby on Rails Workshop - Sesssion 5
PLAT-8 Spring Web Scripts and Spring Surf
GIB2021 - Testing with Postman
SpringMVC
Modern javascript
Web Application Frameworks (WAF)
Why use Go for web development?
Capybara-Webkit
Hands on Gradle
PLAT-7 Spring Web Scripts and Spring Surf
Webcomponents are your frameworks best friend
Ember and SharePoint
Behaviour driven development present
Stackup New Languages Talk: Ember is for Everybody
Automating JavaScript testing with Jasmine and Perl
Day 8 - jRuby
Azkaban-en
Gemboys
Frameworks and webcomponents
Ad

Viewers also liked (14)

PDF
PageObectPattern
PPTX
selenium-cucumber
PPTX
Nasdanika WebTest - Modular functional testing of Web and Mobile Applications
PDF
Selenium Page Objects101
PPTX
MyHeritage - End 2 End testing Infra
PDF
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
PDF
Selenium - The page object pattern
PPTX
Building frameworks over Selenium
PPTX
Out of box page object design pattern, java
PDF
Page Objects Done Right - selenium conference 2014
PPTX
Write Selenide in Python 15 min
DOCX
Realtime selenium interview questions
DOCX
Selenium interview questions
PDF
Kiss PageObjects [01-2017]
PageObectPattern
selenium-cucumber
Nasdanika WebTest - Modular functional testing of Web and Mobile Applications
Selenium Page Objects101
MyHeritage - End 2 End testing Infra
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Selenium - The page object pattern
Building frameworks over Selenium
Out of box page object design pattern, java
Page Objects Done Right - selenium conference 2014
Write Selenide in Python 15 min
Realtime selenium interview questions
Selenium interview questions
Kiss PageObjects [01-2017]
Ad

Similar to Cucumber (20)

PPTX
Cucumber
PDF
Ruby onrails cucumber-rspec-capybara
PPTX
BDD / cucumber /Capybara
PDF
Cucumber Upgrade
PDF
Cucumber
PPT
Cucumber
PDF
How to eat Cucmber
PPTX
Behavior Driven Development Testing (BDD)
KEY
Cucumber, Cuke4Duke, and Groovy
ODP
BDD with Cucumber
PDF
cucumber harpal.pdf
PDF
Cucumber tutorial
PDF
Behavior Driven Development with Cucumber
PPTX
CUCUMBER - Making BDD Fun
PDF
Behavior Driven Development and Automation Testing Using Cucumber
PPT
Integration and Acceptance Testing
PPTX
Testing with cucumber testing framework
PPTX
Introduce cucumber
PPTX
Cucumber_Training_ForQA
PPT
Selenium and Cucumber Selenium Conf 2011
Cucumber
Ruby onrails cucumber-rspec-capybara
BDD / cucumber /Capybara
Cucumber Upgrade
Cucumber
Cucumber
How to eat Cucmber
Behavior Driven Development Testing (BDD)
Cucumber, Cuke4Duke, and Groovy
BDD with Cucumber
cucumber harpal.pdf
Cucumber tutorial
Behavior Driven Development with Cucumber
CUCUMBER - Making BDD Fun
Behavior Driven Development and Automation Testing Using Cucumber
Integration and Acceptance Testing
Testing with cucumber testing framework
Introduce cucumber
Cucumber_Training_ForQA
Selenium and Cucumber Selenium Conf 2011

Cucumber

  • 2. Cucumber... • is not just about testing • is more than integration testing • is behaviour driven development
  • 3. The TDD/BDD Way • Red • Green • Refactor
  • 4. The Cucumber Way 1. Describe behaviour in plain text 2. Write a step definition in Ruby 3. Run and watch it fail 4. Write code to make the step pass 5. Run again and see the step pass 6. Repeat 2-5 until green like a cuke 7. Repeat 1-6 until the money runs out
  • 5. Cucumber Terminology • Features • In order to business value, • As a role, • I want to feature • Scenarios • Given, When, Then • Step Definitions
  • 6. Cucumber Setup • features directory • plain text .feature files • step_definitions folder • ruby steps files • support folder
  • 9. The AMC Way • Use Cucumber with: • Webrat (built-in support) • Machinist (fixture replacement) • Ian White’s Pickle (extends Cucumber) • Profiles • Tags • Scenario Outlines • Background
  • 10. Webrat • browser simulator • used by Cucumber by default • common action step definitions predefined using webrat (webrat_steps.rb): When I press “Log in” Then I should see “Login successful”
  • 11. Machinist • Fixture replacement • Allows you to work with real objects: User.make User.make(:name => ‘Bob’)
  • 12. Pickle (for objects) • Uses Machinist, Factory Girl or ActiveRecord • Provides step definitions for your convenience (pickle_steps.rb): Given a user exists Given a user exists with name: “Bob”
  • 13. Pickle (for paths) • Extends paths.rb: When I go to the users page When I go to the user’s articles page
  • 14. Pickle (for email) • Provides step definitions for your convenience (email_steps.rb): Given all emails have been delivered Then 1 email should be delivered to “bob@uncle.com”
  • 15. No New Steps Required Scenario: delivering comment notification to one user Given a question exists And a user exists with name: “Bob”, email: “uncle@bob.com” When I go to the question's page When I fill in "comment[body]" with "My comment" And I check “Bob” And I press "Add Comment" Then 1 email should be delivered to “uncle@bob.com” And I should see “Comment notification was sent”
  • 16. Cucumber Profiles • defined in cucumber.yml • our current profiles: • default • sphinx • selenium
  • 17. Default Profile • uses transactional fixtures (wraps each scenario in a database transaction) • uses webrat • excludes sphinx and selenium features
  • 18. Sphinx Profile • for testing features that use thinking-sphinx • won’t work with transactional fixtures • use database cleaner gem instead • uses webrat • specifies only sphinx features
  • 19. Selenium Profile • useful for testing javascript features • won’t work with transactional fixtures • use database cleaner gem instead • uses selenium webrat configuration • drives a real browser • specifies only selenium features
  • 20. Using Profiles cucumber cucumber -p sphinx cucumber -p selenium
  • 21. Cucumber Tags • used to target features and scenarios • used by profiles: cucumber -t sphinx • use @wip for feature or scenario that you are currently working on: cucumber -t wip
  • 22. Cucumber Tags • Add directly above Feature or Scenario keywords • Can have more than one (comma separated)
  • 24. Scenario Outlines • Useful for DRYing up your scenarios when only data is changing • Use Scenario Outline instead of Scenario
  • 26. Background • Add context for your scenarios in a single feature
  • 27. And More... • Some other Cucumber features: • Nested steps • Hooks • Multi-line step arguments • Spork and --drb • Cucumber continues to grow!

Editor's Notes