-
-
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
Cucumber does not go to AfterStep if the step is failed! #1026
Comments
@hangnguyenthuy this is by design. AfterStep hooks are compiled in as extra test steps, and run as part of the scenario. In 3.0.0, you'll be able to use an an event, specifically the AfterTestStep event. I'm working on the documentation for this now, and would love to have you try it out to see if it makes sense. I'll leave this ticket open and ping you when I have something. |
@mattwynne I have used test_step_finished event. Now I can capture page screenshot of every step even the step is failed, it is so cool! Thanks a lot. |
👍 nice one @Lupeipei! |
@mattwynne I am trying the same thing as @Lupeipei did capturing screenshot of every step even the step is failed but it didn't work for me. Here's my piece of code. AfterConfiguration do |config| Any suggestions ? |
@sandhusatnam it's hard to say... what didn't work? Did you see the |
@mattwynne Thanks for your reply. |
@sandhusatnam try replacing I think the bug here is that Cucumber’s own |
@sandhusatnam @mattwynne I'm having the same problem. |
@aslakhellesoy I am not using the AfterStep hook, I am trying to add a event in AfterConfiguration hook. |
@FedericoHenze can you share the code snippet ? |
getScreenshotName() is in env.rb and added to the cucumber world.
|
@FedericoHenze try defining your webdriver instance in env.rb file and then access it in your hooks and step file. Let me know if that works |
@sandhusatnam same result, I guess is not a @driver problem because everything is nil also the self instance |
Can you please be more specific than "doesn't work"? Whnat are you seeing and what did you expect to see instead? |
@aslakhellesoy well I am not able to see anything neither with puts nor with Kernel.puts. |
@sandhusatnam here are the scenarios for this feature: these are tested and passing. Can you see what's different between your code and the examples? |
@mattwynne well I am able to print puts statement using the code snippet you mentioned above, but the test_step_results are weird. Also I am not able to attach the screenshot using event. |
Ha! I think that's because they use unicode characters for check-marks and crosses to indicate passes or failure. They're probably not coming through on your terminal for some reason. Try printing |
@mattwynne Great that works but what about the screenshot ? Any suggestion ? |
@mattwynne I got it its not able to add screenshot because the web driver instance is nil, not sure why so as I am able to run the test case. Also, the puts statements are not being included in the json_report. |
Hi @mattwynne Below is the example. AfterConfiguration do |config|
config.on_event :test_step_finished do |event|
if event.result.failed?
$logger.error("Exception received as #{How can I log the error message?}")
end
end
end Any suggestions ? |
Hi @RameshGhk. Please try not to use GitHub issues for support. Asking in Slack is a much better choice in future for faster response. The If it's a |
Hi @mattwynne , |
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. |
Summary
Originally raised in cucumber/common#26 (comment) by @hangnguyenthuy
I'm using Cucumber 2.3.3
I want to print some log after each step so I have my code like this:
But in case the step is failed, it never goes to AfterStep, it move to After scenario so I cannot print log of the failed step.
Right now I have to work around in this case.
Anybody has same problem to me?
The text was updated successfully, but these errors were encountered: