You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

nested_steps.feature 5.2 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. Feature: Nested Steps
  2. Background:
  3. Given a scenario with a step that looks like this:
  4. """gherkin
  5. Given two turtles
  6. """
  7. And a step definition that looks like this:
  8. """ruby
  9. Given /a turtle/ do
  10. log "turtle!"
  11. end
  12. """
  13. Scenario: Use #steps to call several steps at once
  14. Given a step definition that looks like this:
  15. """ruby
  16. Given /two turtles/ do
  17. steps %{
  18. Given a turtle
  19. And a turtle
  20. }
  21. end
  22. """
  23. When I run the feature with the progress formatter
  24. Then the output should contain:
  25. """
  26. turtle!
  27. turtle!
  28. """
  29. Scenario: Use #step to call a single step
  30. Given a step definition that looks like this:
  31. """ruby
  32. Given /two turtles/ do
  33. step "a turtle"
  34. step "a turtle"
  35. end
  36. """
  37. When I run the feature with the progress formatter
  38. Then the output should contain:
  39. """
  40. turtle!
  41. turtle!
  42. """
  43. Scenario: Use #steps to call a table
  44. Given a step definition that looks like this:
  45. """ruby
  46. Given /turtles:/ do |table|
  47. table.hashes.each do |row|
  48. log row[:name]
  49. end
  50. end
  51. """
  52. And a step definition that looks like this:
  53. """ruby
  54. Given /two turtles/ do
  55. steps %{
  56. Given turtles:
  57. | name |
  58. | Sturm |
  59. | Liouville |
  60. }
  61. end
  62. """
  63. When I run the feature with the progress formatter
  64. Then the output should contain:
  65. """
  66. Sturm
  67. Liouville
  68. """
  69. Scenario: Use #steps to call a multi-line string
  70. Given a step definition that looks like this:
  71. """ruby
  72. Given /two turtles/ do
  73. steps %Q{
  74. Given turtles:
  75. \"\"\"
  76. Sturm
  77. Liouville
  78. \"\"\"
  79. }
  80. end
  81. """
  82. And a step definition that looks like this:
  83. """ruby
  84. Given /turtles:/ do |string|
  85. log string
  86. end
  87. """
  88. When I run the feature with the progress formatter
  89. Then the output should contain:
  90. """
  91. Sturm
  92. Liouville
  93. """
  94. @todo-jruby @wip-jruby
  95. Scenario: Backtrace doesn't skip nested steps
  96. Given a file named "features/nested_steps.feature" with:
  97. """gherkin
  98. Feature: nested steps
  99. Scenario: Test Scenario 1
  100. Given two turtles
  101. """
  102. Given a file named "features/step_definitions/step_definition.rb" with:
  103. """ruby
  104. Given /two turtles/ do
  105. step "I have a couple turtles"
  106. end
  107. When(/I have a couple turtles/) { raise 'error' }
  108. """
  109. When I run `cucumber features/nested_steps.feature --format progress`
  110. Then it should fail with:
  111. """
  112. error (RuntimeError)
  113. ./features/step_definitions/step_definition.rb:5:in `/I have a couple turtles/'
  114. ./features/step_definitions/step_definition.rb:2:in `/two turtles/'
  115. features/nested_steps.feature:4:in `two turtles'
  116. Failing Scenarios:
  117. cucumber features/nested_steps.feature:3 # Scenario: Test Scenario 1
  118. 1 scenario (1 failed)
  119. 1 step (1 failed)
  120. """
  121. Scenario: Undefined nested step
  122. Given a file named "features/call_undefined_step_from_step_def.feature" with:
  123. """
  124. Feature: Calling undefined step
  125. Scenario: Call directly
  126. Given a step that calls an undefined step
  127. Scenario: Call via another
  128. Given a step that calls a step that calls an undefined step
  129. """
  130. And a file named "features/step_definitions/steps.rb" with:
  131. """
  132. Given /^a step that calls an undefined step$/ do
  133. step 'this does not exist'
  134. end
  135. Given /^a step that calls a step that calls an undefined step$/ do
  136. step 'a step that calls an undefined step'
  137. end
  138. """
  139. When I run `cucumber -q features/call_undefined_step_from_step_def.feature`
  140. Then it should fail with exactly:
  141. """
  142. Feature: Calling undefined step
  143. Scenario: Call directly
  144. Given a step that calls an undefined step
  145. Undefined dynamic step: "this does not exist" (Cucumber::UndefinedDynamicStep)
  146. ./features/step_definitions/steps.rb:2:in `/^a step that calls an undefined step$/'
  147. features/call_undefined_step_from_step_def.feature:4:in `a step that calls an undefined step'
  148. Scenario: Call via another
  149. Given a step that calls a step that calls an undefined step
  150. Undefined dynamic step: "this does not exist" (Cucumber::UndefinedDynamicStep)
  151. ./features/step_definitions/steps.rb:2:in `/^a step that calls an undefined step$/'
  152. ./features/step_definitions/steps.rb:6:in `/^a step that calls a step that calls an undefined step$/'
  153. features/call_undefined_step_from_step_def.feature:7:in `a step that calls a step that calls an undefined step'
  154. Failing Scenarios:
  155. cucumber features/call_undefined_step_from_step_def.feature:3
  156. cucumber features/call_undefined_step_from_step_def.feature:6
  157. 2 scenarios (2 failed)
  158. 2 steps (2 failed)
  159. """

No Description

Contributors (1)