Skip to content
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

Adding Test Step in AfterStep feature file. #931

Merged
merged 7 commits into from
Apr 19, 2016
Merged

Adding Test Step in AfterStep feature file. #931

merged 7 commits into from
Apr 19, 2016

Conversation

t-morgan
Copy link
Contributor

Working on Add step to AfterStep #450

Do you think the argument list should be consistent with how formatters work or will it potentially cause problems moving the current argument out of its position as first argument?

@brasmusson
Copy link
Contributor

Isn't not having scenario as first argument to the AfterStep hooks, such a breaking change that only can be introduced in a major version upgrade?

If the intention is to add both step and result as arguments to AfterStep hooks, I see it as two separate changes, from:

Before do | scenario |
After do | scenario |
AfterStep do | scenario |

to:

Before do | scenario |
After do | scenario |
AfterStep do | scenario, step |

And another change to.

Before do | scenario |
After do | scenario, scenario_result |
AfterStep do | scenario, step, step_result |

@t-morgan
Copy link
Contributor Author

I could be wrong, but it seems to me that since upgrading to Cucumber 2 the only argument I an receiving from the AfterStep hook is a Cucumber::Core::Test::Result of whatever status the step invocation was.

@brasmusson
Copy link
Contributor

Hm, based on #450 I thought that the AfterStep hooks in Cucumber v2 received a Cucumber::RunningTestCase, as the Before and After hooks do.

@t-morgan
Copy link
Contributor Author

It was definitely a scenario object in Cucumber 1.x when the issue was first reported (and it was pretty simple to get the step through that scenario at the time).

In Cucumber 2.x, I am only finding a result in the AfterStep block (Before and After still receive the scenario as normal).

I know I can add the test_step when the hook action is created in the after_step_hooks method of Cucumber::Runtime::StepHooks in lib/cucumber/runtime/step_hooks.rb and my test will pass... I'm just not sure if that is the right/best place to do it.

@t-morgan
Copy link
Contributor Author

I went ahead and implemented my change to fix the AfterStep hook functionality. If there are any changes that should be made, please let me know.

I had to flatten an array in lib/cucumber/rb_support/rb_hook.rb because the argument passed into the AfterStep hook was being wrapped in an Array for some reason.

@mattwynne
Copy link
Member

Thanks sharing your fix @t-morgan.

@mattwynne
Copy link
Member

Could you rename the feature (and reword the description) to just be a general feature for AfterStep hooks? It should live here: https://github.com/cucumber/cucumber-ruby/tree/master/features/docs/writing_support_code

@t-morgan
Copy link
Contributor Author

Hey @mattwynne, I cleaned up the feature file and moved it as you requested. I think it might be a good idea to also include another scenario showing AfterSteps do run for background steps (apparently this was not always the case).

@maxmeyer
Copy link
Member

@t-morgan What would be a "background step"? Some command running in the background?

@t-morgan
Copy link
Contributor Author

@maxmeyer, it is just a step defined under 'Background:' for the feature.

@maxmeyer
Copy link
Member

Ah. Ok. :-)

@borsothy
Copy link

borsothy commented Feb 9, 2016

Are you about to merge this to master? We're planning to measure the time it takes a step to complete, and this modification would be extremely useful.

glennpratt added a commit to acquia/cucumber-ruby that referenced this pull request Feb 22, 2016
Adding Test Step in AfterStep feature file.

See cucumber#931
@chewi
Copy link

chewi commented Mar 7, 2016

Please merge it, AfterStep is quite useless in its current form.

@chewi
Copy link

chewi commented Mar 7, 2016

Is there a nicer way to get the index of the step other than this?

step.source[-2].children.index(step.source.last)

@mattwynne mattwynne merged commit 8b347ca into cucumber:master Apr 19, 2016
@mattwynne
Copy link
Member

Thanks @t-morgan!

@mattwynne
Copy link
Member

As part of our new policy I've invited you to become a committer to this repo @t-morgan. I liked how you found your way around the code and tested your change. I hope we'll get more contributions from you in future!

@djwgit
Copy link

djwgit commented May 13, 2016

applied the fix to my local 2.3.3 install, it works... thanks...
hope 2.3.4 is coming out soon...

@lock
Copy link

lock bot commented Oct 25, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants