Your SlideShare is downloading. ×

Cucumber

2,169

Published on

An introductory technical presentation on Cucumber and some of its new features. Written in 2010.

An introductory technical presentation on Cucumber and some of its new features. Written in 2010.

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,169
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Our EvolvingDevelopment Framework
    • 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 Way1. Describe behaviour in plain text2. Write a step definition in Ruby3. Run and watch it fail4. Write code to make the step pass5. Run again and see the step pass6. Repeat 2-5 until green like a cuke7. 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
    • 7. Feature & Scenario Example
    • 8. Step Definition Examples
    • 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 questions 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 Profilescucumbercucumber -p sphinxcucumber -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)
    • 23. Scenario Outlines
    • 24. Scenario Outlines• Useful for DRYing up your scenarios when only data is changing• Use Scenario Outline instead of Scenario
    • 25. Background
    • 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!

    ×