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.

ambiguous_steps.feature 2.1 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Feature: Ambiguous Steps
  2. When Cucumber searches for a step definition for a step, it might find multiple step
  3. definitions that could match. In that case, it will give you an error that the step
  4. definitions are ambiguous.
  5. You can also use a `--guess` mode, where it uses magic powers to try and figure
  6. out which of those two step definitions is most likely to be the one you meant it
  7. to use. Use it with caution!
  8. Scenario: Ambiguous steps
  9. Given a file named "features/ambiguous.feature" with:
  10. """
  11. Feature:
  12. Scenario:
  13. When a step
  14. Then an ambiguous step
  15. """
  16. And a file named "features/step_definitions.rb" with:
  17. """
  18. When(/^a.*step$/) do
  19. 'foo'
  20. end
  21. Then(/^an ambiguous step$/) do
  22. 'bar'
  23. end
  24. """
  25. When I run `cucumber`
  26. Then it should fail with:
  27. """
  28. Ambiguous match of "an ambiguous step":
  29. features/step_definitions.rb:1:in `/^a.*step$/'
  30. features/step_definitions.rb:5:in `/^an ambiguous step$/'
  31. You can run again with --guess to make Cucumber be more smart about it
  32. (Cucumber::Ambiguous)
  33. features/ambiguous.feature:5:in `an ambiguous step'
  34. Failing Scenarios:
  35. cucumber features/ambiguous.feature:3 # Scenario:
  36. 1 scenario (1 failed)
  37. 2 steps (1 failed, 1 passed)
  38. 0m0.012s
  39. """
  40. Scenario: Ambiguous steps with guess mode
  41. Given a file named "features/ambiguous.feature" with:
  42. """
  43. Feature:
  44. Scenario:
  45. When a step
  46. Then an ambiguous step
  47. """
  48. And a file named "features/step_definitions.rb" with:
  49. """
  50. When(/^a.*step$/) do
  51. 'foo'
  52. end
  53. Then(/^an ambiguous step$/) do
  54. 'bar'
  55. end
  56. """
  57. When I run `cucumber -g --publish-quiet`
  58. Then it should pass with exactly:
  59. """
  60. Feature:
  61. Scenario: # features/ambiguous.feature:3
  62. When a step # features/step_definitions.rb:1
  63. Then an ambiguous step # features/step_definitions.rb:5
  64. 1 scenario (1 passed)
  65. 2 steps (2 passed)
  66. 0m0.012s
  67. """

No Description

Contributors (1)