integration testing in ruby with rspec s story automation
play

Integration Testing in Ruby with RSpecs Story Automation - PowerPoint PPT Presentation

Integration Testing in Ruby with RSpecs Story Automation Framework David Chelimsky articulatedman.com Behaviour-Driven Development BDD Writing software that matters - Dan North BDD Dan North/Aslak Hellesy 2004 Improve


  1. Integration Testing in Ruby with RSpec’s Story Automation Framework David Chelimsky articulatedman.com

  2. Behaviour-Driven Development

  3. BDD Writing software that matters - Dan North

  4. BDD • Dan North/Aslak Hellesøy 2004 • Improve communication about Test Driven Development • JBehave

  5. BDD • Second generation “full stack” Agile methodology rooted in: • Extreme Programming • Acceptance Test Driven Planning • Test Driven Development

  6. RSpec

  7. RSpec • Behaviour Driven Development Framework • Story Framework • Acceptance Test Driven Planning • Example Framework • Test Driven Development

  8. RSpec Origins • Inspired by a blog post by Dave Astels • Authored by Steven Baker • Summer ‘05 • Maintained by me • Since Summer ‘06 http://daveastels.com/2005/07/05/a-new-look-at-test-driven-development/

  9. BDD Process

  10. Process • Inject features discovered through analysis • Feature Injection - Chris Matts • Extract stories from features • Focus on outputs • Break stories down into scenarios • Acceptance Criteria

  11. Feature Injection

  12. Popping the “Why?” Stack

  13. I want people to be able to register

  14. Why?

  15. I want to know how many people registered

  16. Why?

  17. So I can measure progress towards registration goals

  18. Why?

  19. This is getting really, really annoying

  20. I know ...

  21. Why?

  22. Why do you want to measure progress towards registration goals?

  23. SO I CAN MANAGE COST

  24. Popping the “Why?” Stack • If you keep asking “why?”, you’ll eventually land on one of: • Generate/protect revenue • Reduce/manage cost • When you do, the answer to the previous “why?” is often a feature waiting to be discovered.

  25. User Stories • High level analysis and planning tool • “Token for a conversation”

  26. BDD User Stories • Add Scenarios that serve as Acceptance Criteria

  27. So what does this all have to do with Integration Testing?

  28. Integration Testing • Make sure the component parts play nice together

  29. Automated User Stories/Scenarios • Document the expected behaviour of the system • Verify that behaviour by executing a thin vertical slice of the system

  30. Conference Organizer (Example Application)

  31. Example Story

  32. Example Story Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  33. Title Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  34. Narrative Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  35. Scenarios Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  36. Narrative Format “The Connextra Format”

  37. As a Role Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  38. I want Action Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  39. So that Goal Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  40. Narrative Format • Completely arbitrary, but ... • Look for a format that • Identifies the goal • Identifies the user/persona • Identifies the action

  41. Alternate Format Story: measure progress towards registration goals In order to measure progress towards registration goals As a conference organizer I want to see a report of registrations Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  42. Scenario Format

  43. Given | When | Then The other GWT

  44. Given | When | Then • A simple way of saying: • Pre-conditions, Event, Post-conditions • Context, Action, Outcome • Build, Operate, Check • Uncle Bob Martin

  45. Given | When | Then • Words that can be understood equally well by: • stakeholders • business analysts • developers • testers

  46. Given Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  47. When Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  48. Then Story: measure progress towards registration goals As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals Scenario: one registration shows as 1% Given a goal of 200 registrations When 1 attendee registers Then the goal should be 1% achieved Scenario: one registration less than the goal shows as 99% Given a goal of 200 registrations When 199 attendees register Then the goal should be 99% achieved

  49. Automation

  50. Ruby Story "measure progress towards registration goals",%( As a conference organizer I want to see a report of registrations So that I can measure progress towards registration goals ), :type => RailsStory, :steps_for => :registrations do Scenario "one registration shows as 1%" do Given "a goal of 200 registrations" When "1 attendee registers" Then "the goal should be 1% achieved" end Scenario "one registration less than the goal shows as 99%" do Given "a goal of 200 registrations" When "199 attendees register" Then "the goal should be 99% achieved" end end

Recommend


More recommend