Change to use worst Test Step result as the Test Case result#317
Change to use worst Test Step result as the Test Case result#317brasmusson wants to merge 3 commits intomainfrom
Conversation
When calculating the Test Case result Cucumber-Ruby-Core should conform with the GetWorstTestCaseResult function used in the Messages module.
|
Haven't got round to fully reviewing but we have this concept in messages |
Use test_step_result_rankings from Cucumber::Messages::Helpers::TestStepResultComparator to compare test results to find the worst one.
|
@luke-hill Yes |
I think it does, plus the flaky bit. So I don't mind which way we do things tbh. There's lots of refactors I want to do once cucumber-ruby v11 is released (Just waiting on fixing up last CCK bits). |
luke-hill
left a comment
There was a problem hiding this comment.
Can I ask that without this change what is currently happening / going wrong.
Also should this be included as a minimum for cucumber v11? I'm soon about to cut it and want to get everything sewn up at the same time ideally
| step_result.with_duration(duration) | ||
| result = result.with_message(%(Undefined step: "#{test_step.text}")) if result.undefined? | ||
| result = result.with_appended_backtrace(test_step) unless test_step.hook? | ||
| result.describe_to(monitor, result) |
There was a problem hiding this comment.
Is this the bit that does the magic stuff? I know these methods are a bit obscure for me
There was a problem hiding this comment.
The important here is that the only difference between NotPassing.execute and Base.execute is whether skip or execute is called on the test_step. Previously this method was written under the assumption that when the runner has entered "skip mode" the only possible results are skipped and undefined. This is not true. Hooks can result in passing or failing results. Ambiguous steps result in ambiguous results. pending results is very unlikely be who knows, someone might write a after hook the raises a Pending exception.
After calling skip on the test_step, NotPassing.execute shall be the same as Base.execute, that is:
- Add a message with the step text to
undefinedresults - Add any backtrace from the test_step to the result unless it is a hook
- Pass is (let it describe itself to the RunningTestCase so it can update the result for the test case as a whole if applicable. The line
result.describe_to(monitor, result)will in the end either runRunningTestCase.passedorRunningTestCase.not_passing(depending what type of result that have occurred so far).
There was a problem hiding this comment.
I assume this "repeated" rewriting / over assignment is possible because a lot of the describe and other methods are returning self
Without this if a scenario has only an undefined step and an after hook fails, the summary report will say instead of the expected: Without this if a scenario has one undefined step (or pending) followed by an ambiguous step, the summary report will say instead of the expected: |
|
Ooooh ok. This might actually help me then with some of the work I need to do for messages and @davidjgoss will hopefully be able to help with this. We have 3 CCK examples currently failing, two of which are regarding hooks failing. Also are these only specific to the Also what would happen if it were Before Hooks that failed. Or BeforeAll hooks |
|
It is the |
luke-hill
left a comment
There was a problem hiding this comment.
Reviewed 3 and a bit files out of the 5. Got a few questions, but I get what is being done here.
|
|
||
| def not_passing(step_result) | ||
| @status = Status::NotPassing.new(step_result) if test_step_result_rankings[step_result.to_message.status] > test_step_result_rankings[status.step_result_message.status] | ||
| self |
There was a problem hiding this comment.
I'm not sure this self call is needed here, as the not_passing invocation returns self afterwards
| private | ||
|
|
||
| def not_passing(step_result) | ||
| @status = Status::NotPassing.new(step_result) if test_step_result_rankings[step_result.to_message.status] > test_step_result_rankings[status.step_result_message.status] |
There was a problem hiding this comment.
I can see we have status defined as an iVar and I assume it's defined somewhere in here, but I can't see it.
| step_result.with_duration(duration) | ||
| result = result.with_message(%(Undefined step: "#{test_step.text}")) if result.undefined? | ||
| result = result.with_appended_backtrace(test_step) unless test_step.hook? | ||
| result.describe_to(monitor, result) |
There was a problem hiding this comment.
I assume this "repeated" rewriting / over assignment is possible because a lot of the describe and other methods are returning self
| @@ -118,6 +128,10 @@ def execute(test_step, monitor, &) | |||
| def result | |||
| raise NoMethodError, 'Override me' | |||
There was a problem hiding this comment.
I cannot see where result (Which is defined in the two child classes - Passing and NotPassing will use the result defined there.
| let(:test_steps) { [undefined_step, passing_step] } | ||
|
|
||
| it 'emits a test_step_finished event with an undefined result' do | ||
| expect(event_bus).to receive(:test_step_finished).with(undefined_step, anything) do |_reported_test_case, result| |
There was a problem hiding this comment.
Where is anything defined.
Or are we simply saying here it's irrelevant what it receives. Wouldn't it be a passing step due to line 255?
| end | ||
|
|
||
| it 'emits a test_step_finished event with a skipped result' do | ||
| expect(event_bus).to receive(:test_step_finished).with(passing_step, anything) do |_reported_test_case, result| |
There was a problem hiding this comment.
Shouldn't all these shadowing wrapper methods be allow just to permit it through. Won't / Shouldn't we be doing diff assertions based on this not appearing?
There was a problem hiding this comment.
Ah I think this actually should be an ordered set of results. Maybe like here? https://github.com/site-prism/site_prism/blob/v2.15.1/spec/sections_spec.rb#L50-L55
Description
Change to use worst Test Step result as the Test Case result
When calculating the Test Case result Cucumber-Ruby-Core should conform with the GetWorstTestCaseResult function used in the Messages module.
Type of change
Please delete options that are not relevant.
Please add an entry to the relevant section of CHANGELOG.md as part of this pull request.
Note to other contributors
If your change may impact future contributors, explain it here, and remember to update README.md and CONTRIBUTING.md accordingly.
Checklist:
Your PR is ready for review once the following checklist is
complete. You can also add some checks if you want to.
bundle exec rubocopreports no offenses