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

Issues: 997 - Adding beforeStep/afterStep hooks #1198

Closed

Conversation

Andras-Marozsi
Copy link

@Andras-Marozsi Andras-Marozsi commented Apr 25, 2019

This is my proposed solution for the problem: #997
Basically I'm treating the beforeStep/afterStep hooks as steps, which allowed me to integrate them with minimal change.

Please let me know what you think about this solution, or if you want me to update/change something.

@Andras-Marozsi
Copy link
Author

@Eis95, @charlierudolph, could you please check this PR?

@navneetgarg123
Copy link

Any updates on this PR? This functionality would solve a lot of our problems. Really hoping this gets in soon.

@Andras-Marozsi
Copy link
Author

Andras-Marozsi commented Jun 25, 2019

I'm still waiting for some/any feedback, pinged a couple of guys here and in the issue ticket as well, no response yet.

@nelsonthedev
Copy link

I'm also looking forward to have this solution

@loganvolkers
Copy link

loganvolkers commented Jul 16, 2019

@Andras-Marozsi I think one thing that's missing in this PR is actually .feature files for this new functionality. For a similar example, see the "before all hooks" feature: https://github.com/cucumber/cucumber-js/blob/master/features/before_after_all_hooks.feature

Feature files provides some documentation around usage, too.

You may be able to steal the starting point for that from #1058

@Andras-Marozsi
Copy link
Author

Thanks @loganvolkers, will look at that PR for ideas.

@Andras-Marozsi
Copy link
Author

@loganvolkers, I updated the PR with the feature file. Could you be so kind and check it? Let me know if I should add anything else. Thanks!

@icloudphil
Copy link

how can we help to merge this feature into the master? Thanks!

@Andras-Marozsi
Copy link
Author

@expphchen, find someone who's willing to provide feedback :)
I couldn't get any response so far, tried it here in this PR, and also pinged people in the issue ticket. I'm happy to update my solution if it's not fit to be merged. It would be my first contribution to cucumber-js, I don't know the process.

@charlierudolph
Copy link
Member

Sorry haven't really looked at this. There will probably be some changes needed for this after retry goes in as that has ended up being a major overhaul

@Andras-Marozsi
Copy link
Author

@charlierudolph, np, thanks for checking now.
So you think we should wait with this PR until the retry work goes in? When do you think this will happen?

@charlierudolph
Copy link
Member

Alright retry is in. This should be good to start work on again.

Sorry hadn't gotten around to reviewing this until now.

I agree more with the process as defined in other PR (before / after steps aren't treated as full steps - don't appear in test case prepared, do not trigger test step events). Given the use case for this as extra validation / debugging I don't think need to be full steps.

text: step.text,
arguments: step.arguments,
location: Object.assign({ uri: this.testCase.uri }, step.locations[0]),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest for beforeStep the hookParameter is {step, testCase: {sourceLocation, pickle}} where source location / pickle is what we pass to before / after hooks. And for afterStep we use {step, testCase: {sourceLocation, pickle}, result} where result is the step result.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will have a look towards the end of this week.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found a solution. Still need to test it, but will update the pr soon.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charlierudolph, updated the branch. It's not complete, I didn't add additional tests, just made sure nothing breaks. Can you please check it and let me know if you're ok with the solution?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry way late here. The current solution looks good to me. I like the cumulation of before step / step / after step results together. May be worth creating a "test_step_runner" class to encompass the new logic and to make testing a bit easier.

Also note, a lot of things have changed since you last merged master. (Gherkin 9 + cucumber-messages and the conversion to typescript). If you'd like help migrating in the latest changes, let me know.

@icloudphil
Copy link

sorry didn't come back to check for a while, looks like the branch has conflict. would @Andras-Marozsi needs to resolve the conflict or @charlierudolph able to help. :) Thanks you guys on keep the ball rolling.

@Andras-Marozsi
Copy link
Author

@charlierudolph, I updated the PR, keeping the cumulation approach. I didn't add any new tests, and as of now this is breaking some existing tests, so there's some more work to be done on this PR, but before investing more time I want to double check you're ok with this solution.

@charlierudolph
Copy link
Member

Updates look on the right track to me. I do think we should create a TestStepRunner class to encompass the new logic though and probably create a function to cumulate results (update status / message / durations) since appear doing that more now

@Adam-ARK
Copy link
Contributor

Closing this PR since beforeStep/AfterSteps Hooks was promoted in #1416

Thanks @Andras-Marozsi for the work you did. It was a big help in getting my PR for this completed and merged.

@Adam-ARK Adam-ARK closed this Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants