Driving Behaviour with Cucumber

Driving Behaviour with Cucumber

This is a talk I gave at the Great Lakes Software Excellence Conference in 2009 on BDD and Cucumber.

F86901feca747abbb5c6c020362ef2e7?s=128

Zach Dennis

March 20, 2012
Tweet

Transcript

  1. Driving Behaviour with Cucumber Zach Dennis Mutually Human Software www.mutuallyhuman.com

  2. None
  3. later... ...still joyful

  4. a framework for writing and executing high level descriptions of

    your software’s behavior
  5. None
  6. None
  7. Cucumber is not a low level testing/specification framework.

  8. Cucumber is a BDD tool

  9. BDD was reframing of TDD

  10. It has evolved into its own

  11. Dan North’s 3 Principles of BDD

  12. 1. Enough is enough

  13. 2. Deliver stakeholder value

  14. 3. It’s all behaviour

  15. how

  16. None
  17. I want ...

  18. ok, why?

  19. None
  20. In order to reduce time managing contacts users should be

    able to search for contacts within their account
  21. In order to reduce time managing contacts users should be

    able to search for contacts within their account value
  22. In order to reduce time managing contacts users should be

    able to search for contacts within their account role
  23. In order to reduce time managing contacts users should be

    able to search for contacts within their account behaviour
  24. In order to reduce time managing contacts users should be

    able to search for contacts within their account searching contacts
  25. searching contacts details

  26. searching contacts details Searching by name

  27. searching contacts details Searching by name Searching by partial name

  28. searching contacts details Searching by name Searching by partial name

    Searching for non-existent person ...
  29. searching contacts details Searching by partial name Given John Smith

    exists And I’ve logged in as a user When I search for Jo Then I should see John Smith is found
  30. Organizing

  31. Project Management Tools

  32. None
  33. Code Stories Acceptance Criteria Today

  34. Code Stories Acceptance Criteria Near Distant Future

  35. Code Stories Acceptance Criteria Future

  36. Stories Acceptance Criteria Code

  37. None
  38. identify the behaviour first

  39. everything else

  40. Outside-In

  41. UX/IA/IxD Views Controllers Models Database

  42. UX, IA, IxD

  43. Views

  44. Controller

  45. Models

  46. Database

  47. An Example

  48. In order to reduce time managing contacts users should be

    able to search for contacts within their account
  49. searching contacts details Searching by partial name Given John Smith

    exists And I’ve logged in as a user When I search for Jo Then I should see John Smith is found
  50. None
  51. feature title

  52. narrative

  53. notes

  54. acceptance criteria

  55. scenario title

  56. steps

  57. Gherkin

  58. PROJ_ROOT/ features/ step_definitions/ support/ searching_contacts.feature lib/ test/

  59. cucumber features/searching_contacts.feature executable

  60. None
  61. None
  62. pending steps

  63. file/line numbers

  64. step definition snippets

  65. None
  66. Given “John Smith” exists first step

  67. PROJ_ROOT/ features/ step_definitions/ support/ searching_contacts.feature lib/ test/ people_steps.rb

  68. features/step_definitions/people_steps.rb

  69. watch it fail

  70. watch it fail backtrace

  71. None
  72. make it pass

  73. step becomes method invocation Given “John Smith” exists Given /^([^“]+)”

    .../ step definition becomes method definition
  74. capture groups become arguments

  75. And I’ve logged in as a user 2nd step

  76. features/step_definitions/people_steps.rb

  77. watch it fail

  78. None
  79. make it pass

  80. When I search for “Jo” 3rd step

  81. features/step_definitions/search_steps.rb

  82. watch it fail

  83. add routes

  84. still failing

  85. add controller

  86. still failing

  87. add view

  88. still failing

  89. add search action

  90. still failing

  91. add the model

  92. made it pass

  93. Then I should see “John Smith” is found last step

  94. features/step_definitions/people_steps.rb

  95. None
  96. make it pass

  97. None
  98. Rinse Repeat Lather

  99. Stories In Features Out

  100. None
  101. None
  102. features - customer audience tests/specs - developer audience

  103. accurate, readable, executable, features

  104. None
  105. step tables

  106. None
  107. None
  108. table#raw

  109. None
  110. table#hashes

  111. None
  112. table#rows_hash

  113. scenario outlines

  114. None
  115. None
  116. None
  117. None
  118. multi-line strings

  119. None
  120. background

  121. None
  122. None
  123. tags tags

  124. None
  125. None
  126. cucumber --tags @search, @wip

  127. cucumber --tags ~@search,@wip

  128. Hooks Transforms Framework Agnostic Wire Protocol Profiles

  129. .NET - cuke4nuke

  130. steps in .NET

  131. JVM - cuke4duke

  132. steps in java

  133. steps in groovy

  134. steps in scala

  135. None
  136. Resources • http://www.cukes.info • http://github.com/aslakhellesoy/cucumber • http://github.com/aslakhellesoy/cuke4duke • http://github.com/richardlawrence/Cuke4Nuke/