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.

rerun_spec.rb 4.2 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # frozen_string_literal: true
  2. require 'cucumber/formatter/rerun'
  3. require 'cucumber/core'
  4. require 'cucumber/core/gherkin/writer'
  5. require 'support/standard_step_actions'
  6. require 'cucumber/configuration'
  7. require 'support/fake_objects'
  8. module Cucumber
  9. module Formatter
  10. describe Rerun do
  11. include Cucumber::Core::Gherkin::Writer
  12. include Cucumber::Core
  13. let(:config) { Cucumber::Configuration.new(out_stream: io) }
  14. let(:io) { StringIO.new }
  15. # after_test_case
  16. context 'when 2 scenarios fail in the same file' do
  17. it 'Prints the locations of the failed scenarios' do
  18. gherkin = gherkin('foo.feature') do
  19. feature do
  20. scenario do
  21. step 'failing'
  22. end
  23. scenario do
  24. step 'failing'
  25. end
  26. scenario do
  27. step 'passing'
  28. end
  29. end
  30. end
  31. Rerun.new(config)
  32. execute [gherkin], [StandardStepActions.new], config.event_bus
  33. config.event_bus.test_run_finished
  34. expect(io.string).to eq 'foo.feature:3:6'
  35. end
  36. end
  37. context 'with failures in multiple files' do
  38. it 'prints the location of the failed scenarios in each file' do
  39. foo = gherkin('foo.feature') do
  40. feature do
  41. scenario do
  42. step 'failing'
  43. end
  44. scenario do
  45. step 'failing'
  46. end
  47. scenario do
  48. step 'passing'
  49. end
  50. end
  51. end
  52. bar = gherkin('bar.feature') do
  53. feature do
  54. scenario do
  55. step 'failing'
  56. end
  57. end
  58. end
  59. Rerun.new(config)
  60. execute [foo, bar], [StandardStepActions.new], config.event_bus
  61. config.event_bus.test_run_finished
  62. expect(io.string).to eq "foo.feature:3:6\nbar.feature:3"
  63. end
  64. end
  65. context 'when there are no failing scenarios' do
  66. it 'prints nothing' do
  67. gherkin = gherkin('foo.feature') do
  68. feature do
  69. scenario do
  70. step 'passing'
  71. end
  72. end
  73. end
  74. Rerun.new(config)
  75. execute [gherkin], [StandardStepActions.new], config.event_bus
  76. config.event_bus.test_run_finished
  77. expect(io.string).to eq ''
  78. end
  79. end
  80. context 'with only a flaky scenarios' do
  81. context 'with option --no-strict-flaky' do
  82. it 'prints nothing' do
  83. gherkin = gherkin('foo.feature') do
  84. feature do
  85. scenario do
  86. step 'flaky'
  87. end
  88. end
  89. end
  90. Rerun.new(config)
  91. execute [gherkin], [FakeObjects::FlakyStepActions.new], config.event_bus
  92. config.event_bus.test_run_finished
  93. expect(io.string).to eq ''
  94. end
  95. end
  96. context 'with option --strict-flaky' do
  97. let(:config) { Configuration.new(out_stream: io, strict: Core::Test::Result::StrictConfiguration.new([:flaky])) }
  98. it 'prints the location of the flaky scenario' do
  99. foo = gherkin('foo.feature') do
  100. feature do
  101. scenario do
  102. step 'flaky'
  103. end
  104. end
  105. end
  106. Rerun.new(config)
  107. execute [foo], [FakeObjects::FlakyStepActions.new], config.event_bus
  108. config.event_bus.test_run_finished
  109. expect(io.string).to eq 'foo.feature:3'
  110. end
  111. it 'does not include retried failing scenarios more than once' do
  112. foo = gherkin('foo.feature') do
  113. feature do
  114. scenario do
  115. step 'failing'
  116. end
  117. end
  118. end
  119. Rerun.new(config)
  120. execute [foo, foo], [StandardStepActions.new], config.event_bus
  121. config.event_bus.test_run_finished
  122. expect(io.string).to eq 'foo.feature:3'
  123. end
  124. end
  125. end
  126. end
  127. end
  128. end

No Description

Contributors (1)