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.

running_test_case.rb 1.4 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # frozen_string_literal: true
  2. require 'delegate'
  3. module Cucumber
  4. # Represents the current status of a running test case.
  5. #
  6. # This wraps a `Cucumber::Core::Test::Case` and delegates
  7. # many methods to that object.
  8. #
  9. # We decorete the core object with the current result.
  10. # In the first Before hook of a scenario, this will be an
  11. # instance of `Cucumber::Core::Test::Result::Unknown`
  12. # but as the scenario runs, it will be updated to reflect
  13. # the passed / failed / undefined / skipped status of
  14. # the test case.
  15. #
  16. module RunningTestCase
  17. def self.new(test_case)
  18. TestCase.new(test_case)
  19. end
  20. class TestCase < SimpleDelegator
  21. def initialize(test_case, result = Core::Test::Result::Unknown.new)
  22. @test_case = test_case
  23. @result = result
  24. super test_case
  25. end
  26. def accept_hook?(hook)
  27. hook.tag_expressions.all? { |expression| @test_case.match_tags?(expression) }
  28. end
  29. def exception
  30. return unless @result.failed?
  31. @result.exception
  32. end
  33. def status
  34. @result.to_sym
  35. end
  36. def failed?
  37. @result.failed?
  38. end
  39. def passed?
  40. !failed?
  41. end
  42. def source_tag_names
  43. tags.map &:name
  44. end
  45. def with_result(result)
  46. self.class.new(@test_case, result)
  47. end
  48. end
  49. end
  50. end

No Description

Contributors (1)