-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reporting errors from hooks #567
Comments
Haven't managed to get #567 fixed yet, but we're a lot closer now. Probably just a matter of getting the indentation right now.
@os97673 have a look at this one if you want. I've got my head around it now so I can help if you get stuck. |
Sure, I will. |
@mattwynne as far as I can see the problem is not the exception is not printed, but that its location is incorrect :( |
@mattwynne @tooky what would be the correct approach to fix indent calculation? It looks like we have to change our code to not change all features which uses PrettyFormatter.
@mattwynne I've fixed the scenario somehow (see comment for the latter commit). Will investigate why specs are failing later. |
Looks like specs a re failing due to #563 |
@mattwynne @tooky I've reverted my changes in expected output and changed PrettyFormatter to use new indent correctly. But it would be nice to get your feedback on this. |
@os97673 there's a ReportAdapter which is where we are joining the new core to the formatters - I think this line might be the problem: https://github.com/cucumber/cucumber/blob/new-core/lib/cucumber/formatter/report_adapter.rb#L428 |
@tooky I'm not sure which line you tried to point (the line you pointed contains |
@mattwynne I've see this line and decided that this is correct calculation and it is PrettyFormatter who should not add additional space after it. Does this sound reasonable for you? |
@mattwynne @tooky it looks like we currently call before hook BEFORE a scenario, but the tests expect to have exception reported inside the scenario thus we should either store the exception somehow and report it later or run the hook as the very first step INSIDE a scenario. I personally prefer the latter. So what do you think? |
@os97673 @mattwynne @tooky If that is the case then it is a change from the behavior of Cucumber 1.3.x, but interestingly enough the same behavior as Cucumber-JVM. When working on cucumber/gherkin#270 I concluded that Cucumber (1.3.x) and Cucumber-JVM behaves differently with respect to the call sequence that a formatter experience for scenarios with before hooks. Cucumber call the formatter in the sequence:
whereas Cucumber-JVM call the formatter in the sequence:
As a consequence the test of before hook results had to be removed from json_parser_spec.rb, since the Ruby JsonFormatter stores the before hook result in the scenario of the latest call to Scenario (to work together with Cucumber), and the Java JsonFormatter stores the before hook result in the scenario of the next call Scenario (to work together with Cucumber-JVM). With different behavior of the handling of before hooks results, a spec common to both has a hard time test that aspect of the formatters behavior. |
@os97673 it's not quite a simple as that. The compilation that happens in core[1][2] makes a Both types of test steps have the same interface, which includes a Feature: a feature
Scenario: a scenario
Given step 1
And step 2 This would generate a single
When we execute the test case, the core calls the report API with the The thing is that right now, the hook doesn't consider the AST scenario to be part of it's source. So when you ask it to describe it's source, it doesn't tell you about the scenario. I think that's arguable. If we change the way the I hope that makes some kind of sense. Please do ask more questions - the more people who understand this new model the better. [1] https://github.com/cucumber/cucumber-ruby-core/blob/master/lib/cucumber/core/compiler.rb |
@mattwynne base on your explanation I'd say that scenario should be part of hook's source. |
@os97673 I've remembered why this might be a bad idea. If the scenario has a background, the hook won't know about that. Here's how the compiled nodes would look for this scenario:
This is pseudo-code - you can't really transform the test tree into JSON!
So when the hook is printed, we'll look at it's source, print the scenario, and then only when the first step runs we'll print the background. That's wrong. I'm pretty sure the current behaviour is that the background steps should be printed (showing status skipped, which they should have also in the new model) and then the hook error is printed after the A bit messy, but it preserves existing behaviour at least. If you can see a way to improve the model above to allow for this elegantly, please suggest! |
@mattwynne I double checked in Cucumber v1.3.5, and it is a little more complex than that. If a feature has background, the before hook exception will be printed by the PrettyFormatter after the To preserve this behaviour it seems that the ReporterAdapter need to store the before hook results, and when triggering the |
@brasmusson that makes sense. Thanks for looking into it for us. |
This should fix the specs in the cucumber front-end, but it will probably break cucumber/common#567
Looks like this is dealt with in other tickets now. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
If you run
cucumber features/docs/writing_support_code/tagged_hooks.feature:22
on the new-core branch, you'll see that theBefore
hook raises an error correctly, causing the step to be skipped. All that's wrong here is that the error is not reported in the formatter.The text was updated successfully, but these errors were encountered: