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.

exception_in_before_hook.feature 2.9 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. Feature: Exception in Before Block
  2. In order to know with confidence that my before blocks have run OK
  3. As a developer
  4. I want exceptions raised in Before blocks to be handled gracefully and reported by the formatters
  5. Background:
  6. Given the standard step definitions
  7. And a file named "features/support/env.rb" with:
  8. """
  9. class SomeSetupException < Exception; end
  10. class BadStepException < Exception; end
  11. Before do
  12. raise SomeSetupException.new("I cannot even start this scenario")
  13. end
  14. """
  15. Scenario: Handle Exception in standard scenario step and carry on
  16. Given a file named "features/naughty_step_in_scenario.feature" with:
  17. """
  18. Feature: Sample
  19. Scenario: Run a good step
  20. Given this step passes
  21. """
  22. When I run `cucumber features`
  23. Then it should fail with:
  24. """
  25. Feature: Sample
  26. Scenario: Run a good step # features/naughty_step_in_scenario.feature:3
  27. I cannot even start this scenario (SomeSetupException)
  28. ./features/support/env.rb:4:in `Before'
  29. Given this step passes # features/step_definitions/steps.rb:1
  30. Failing Scenarios:
  31. cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Run a good step
  32. 1 scenario (1 failed)
  33. 1 step (1 skipped)
  34. """
  35. Scenario: Handle Exception in Before hook for Scenario with Background
  36. Given a file named "features/naughty_step_in_before.feature" with:
  37. """
  38. Feature: Sample
  39. Background:
  40. Given this step passes
  41. Scenario: Run a good step
  42. Given this step passes
  43. """
  44. When I run `cucumber features --publish-quiet`
  45. Then it should fail with exactly:
  46. """
  47. Feature: Sample
  48. Background: # features/naughty_step_in_before.feature:3
  49. I cannot even start this scenario (SomeSetupException)
  50. ./features/support/env.rb:4:in `Before'
  51. Given this step passes # features/step_definitions/steps.rb:1
  52. Scenario: Run a good step # features/naughty_step_in_before.feature:6
  53. Given this step passes # features/step_definitions/steps.rb:1
  54. Failing Scenarios:
  55. cucumber features/naughty_step_in_before.feature:6 # Scenario: Run a good step
  56. 1 scenario (1 failed)
  57. 2 steps (2 skipped)
  58. 0m0.012s
  59. """
  60. Scenario: Handle Exception using the progress format
  61. Given a file named "features/naughty_step_in_scenario.feature" with:
  62. """
  63. Feature: Sample
  64. Scenario: Run a good step
  65. Given this step passes
  66. """
  67. When I run `cucumber features --format progress`
  68. Then it should fail with:
  69. """
  70. F-
  71. Failing Scenarios:
  72. cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Run a good step
  73. 1 scenario (1 failed)
  74. 1 step (1 skipped)
  75. """

No Description

Contributors (1)