Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
story-driven testing
   people first, computers second.
testing can be frustrating.
testing isn’t fun.
so we don’t do it...
then things break
and users get mad.
so how do you win?
make tests automated!
get users involved!
and enforce policy.
everyone knows why
   testing is good.
and everyone has
excuses why they don’t
         test.
it’s the manager’s job to
     keep projects on
         schedule
it’s the passionate
programmer who fights
        for quality.
testing needs to be
easy (and quick) to do...
and it must be part of
    the schedule.
domain experts first
 and code second.
And I fill in "Email" with "homer@simpsons.com"
Feature: User Signup
  In order to help other people learn Rails and get he...
features are value-
   propositions
focus on features that
  have real business
        value.
As a...
I want to...
So that I can...
Feature: Checking grades
As a nervous student who may not graduate
I want to be able to check my grades in
real time
So th...
Given          Then
        When
scenarios describe the
   feature in detail.
Given
setups, preconditions,
    prerequisites
Given   I   am logged in as "homer"
  And   I   am a current student
  And   I   am on the My Info page
  And   I   receiv...
When



describe actions
When I click "Check my grades"
 And I select "Current term"
 And I press "View"
Then
describes outcomes
Then I should see "Grades for Homer Simpson"
 And I should see a table with "CS 462" in row 1, column 1
 And I should see ...
step definitions make
   this all possible.
step definitions use
Ruby code and regular
 expressions to run
       stories.
but you can run stories
 against any web-based
       application
WEBRAT
webrat is for testing
 rails applications
webrat provides
matchers for cucumber
Web
Application
Testing
In
Ruby
WATIR platforms

• Internet Explorer (Windows)
• Firefox (Windows and Mac)
• Safari (Mac)
steps to definitions
    Then I should see "Grades for Homer Simpson"




Then /I should see "(.*)"/ do |text|
  @browser.t...
multiple parameters
          When I fill in "username" with "bphogan"




When /^I fill in "([^"]*)" with "([^"]*)"$/ do ...
a small demo
Feature: Share code with others
  In order to help a student who is in a different state
  As a good teacher
...
stories automate a
     browser
Many more advanced
   features... but
cucumber lets you keep
 your features with the
          code
and it facilitates
   communication
between technical and
non-technical people.
you will be a hero.
then you win.
questions go to
bphopgan@gmail.com
Upcoming SlideShare
Loading in …5
×

Story-driven Testing

2,633 views

Published on

Using Cucumber to improve the application testing process

Published in: Technology, Business
  • Be the first to comment

Story-driven Testing

  1. 1. story-driven testing people first, computers second.
  2. 2. testing can be frustrating.
  3. 3. testing isn’t fun.
  4. 4. so we don’t do it...
  5. 5. then things break
  6. 6. and users get mad.
  7. 7. so how do you win?
  8. 8. make tests automated!
  9. 9. get users involved!
  10. 10. and enforce policy.
  11. 11. everyone knows why testing is good.
  12. 12. and everyone has excuses why they don’t test.
  13. 13. it’s the manager’s job to keep projects on schedule
  14. 14. it’s the passionate programmer who fights for quality.
  15. 15. testing needs to be easy (and quick) to do...
  16. 16. and it must be part of the schedule.
  17. 17. domain experts first and code second.
  18. 18. And I fill in "Email" with "homer@simpsons.com" Feature: User Signup In order to help other people learn Rails and get help myself And I press "Sign Up" As an interested community member I want to sign up Then I should receive an email Scenario: Signing up to use the system When I open the email Given I go to the home page And I press "Sign up" Then I fill in "Login" with "homer" activate your Rails Mentors And I should see "Please And I press "Sign account" in the subject And I fill in "Email" with "homer@simpsons.com" Up" When I open the email click the first link in the email When I Then I should receive an email When I click the firstshould see "Almost done..." Then I link in the email Then I should see "Please activate your Rails Mentors account" in the subject When I fill in fill in "Password" with "homer_rocks" When I "Password" with "homer_rocks" Then I should see "Almost done..." And I press "Start in "Password Confirmation" with And I fill using your account!" And I fill in "Password Confirmation" with "homer_rocks" "homer_rocks" Then I should be on the dashboard page And I should see "Your account has been activated. Welcome to Rails Mentors!" And I press "Start using your account!" And I should see "Please complete your profile!" Then I should be on the dashboard page And I should see "Your account has been activated. Welcome to Rails Mentors!" And I should see "Please complete your profile!"
  19. 19. features are value- propositions
  20. 20. focus on features that have real business value.
  21. 21. As a... I want to... So that I can...
  22. 22. Feature: Checking grades As a nervous student who may not graduate I want to be able to check my grades in real time So that I know I will get a diploma
  23. 23. Given Then When
  24. 24. scenarios describe the feature in detail.
  25. 25. Given setups, preconditions, prerequisites
  26. 26. Given I am logged in as "homer" And I am a current student And I am on the My Info page And I received a grade of "C-" in "CS 462"
  27. 27. When describe actions
  28. 28. When I click "Check my grades" And I select "Current term" And I press "View"
  29. 29. Then describes outcomes
  30. 30. Then I should see "Grades for Homer Simpson" And I should see a table with "CS 462" in row 1, column 1 And I should see a table with "C-" in row 1, column 4`
  31. 31. step definitions make this all possible.
  32. 32. step definitions use Ruby code and regular expressions to run stories.
  33. 33. but you can run stories against any web-based application
  34. 34. WEBRAT
  35. 35. webrat is for testing rails applications
  36. 36. webrat provides matchers for cucumber
  37. 37. Web Application Testing In Ruby
  38. 38. WATIR platforms • Internet Explorer (Windows) • Firefox (Windows and Mac) • Safari (Mac)
  39. 39. steps to definitions Then I should see "Grades for Homer Simpson" Then /I should see "(.*)"/ do |text| @browser.text.should include(text) end
  40. 40. multiple parameters When I fill in "username" with "bphogan" When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
  41. 41. a small demo Feature: Share code with others In order to help a student who is in a different state As a good teacher I want to share some code I wrote over the internet Scenario: Create a private paste so it won’t be found by Google Given I go to "http://www.pastie.org/" And I fill in "paste[body]" with "This is a simple test case using Cucumber" And I select "Plain text" from "paste_parser_id" And I check "paste[restricted]" When I press "Paste" Then I should see "less than a minute ago" When I click "Edit" Then I should see "This paste will be private."
  42. 42. stories automate a browser
  43. 43. Many more advanced features... but
  44. 44. cucumber lets you keep your features with the code
  45. 45. and it facilitates communication between technical and non-technical people.
  46. 46. you will be a hero.
  47. 47. then you win.
  48. 48. questions go to bphopgan@gmail.com

×