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_around_hook.feature 2.1 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Feature: Exceptions in Around Hooks
  2. Around hooks are awkward beasts to handle internally.
  3. Right now, if there's an error in your Around hook before you call `block.call`,
  4. we won't even print the steps for the scenario.
  5. This is because that `block.call` invokes all the logic that would tell Cucumber's
  6. UI about the steps in your scenario. If we never reach that code, we'll never be
  7. told about them.
  8. There's another scenario to consider, where the exception occurs after the steps
  9. have been run. How would we want to report in that case?
  10. Scenario: Exception before the test case is run
  11. Given the standard step definitions
  12. And a file named "features/support/env.rb" with:
  13. """
  14. Around do |scenario, block|
  15. fail "this should be reported"
  16. block.call
  17. end
  18. """
  19. And a file named "features/test.feature" with:
  20. """
  21. Feature:
  22. Scenario:
  23. Given this step passes
  24. """
  25. When I run `cucumber -q`
  26. Then it should fail with exactly:
  27. """
  28. Feature:
  29. Scenario:
  30. this should be reported (RuntimeError)
  31. ./features/support/env.rb:2:in `Around'
  32. Failing Scenarios:
  33. cucumber features/test.feature:2
  34. 1 scenario (1 failed)
  35. 0 steps
  36. """
  37. Scenario: Exception after the test case is run
  38. Given the standard step definitions
  39. And a file named "features/support/env.rb" with:
  40. """
  41. Around do |scenario, block|
  42. block.call
  43. fail "this should be reported"
  44. end
  45. """
  46. And a file named "features/test.feature" with:
  47. """
  48. Feature:
  49. Scenario:
  50. Given this step passes
  51. """
  52. When I run `cucumber -q`
  53. Then it should fail with exactly:
  54. """
  55. Feature:
  56. Scenario:
  57. Given this step passes
  58. this should be reported (RuntimeError)
  59. ./features/support/env.rb:3:in `Around'
  60. Failing Scenarios:
  61. cucumber features/test.feature:2
  62. 1 scenario (1 failed)
  63. 1 step (1 passed)
  64. """

No Description

Contributors (1)