-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add new hooks for global level (BeforeTests and AfterTests) that run onl... #672
Conversation
…only once before all and after all existing features/scenarios, and new hooks for feature level (BeforeFeature and AfterFeature) that run only one before and after a feature(all scenarios in a feature file). Unit test and cucumber test to cover the new hooks and the running order between hooks.
This seems tested and proved that this works, so I'm okay with merging it. This is something people have asked for reasonably often, so @andryutz10 thanks for doing the work! However, something about this bothers me a little bit. Ah, so It also seems like there are a Whole Lot tm of hooks now, and that there should be a better way of handling injection into the workflow. But I'm not sure what it is, I just see a lot of very similar code that's doing very similar things at different places. |
It may be worth sticking with BDD nomenclature and calling them Then it's obvious what is going on. On 24 February 2014 19:27, David Kowis notifications@github.com wrote:
|
There are two sets of hooks added in the PR
They should probably be handled in separate RP:s.
|
Thanks guys for your time and your suggestions. |
@dkowis, @mikquinlan I added a new commit to this pull request for the renaming you suggested. |
Cool. I might be missing something here, but does this not mean that we now have: @Before/AfterAll - before/after all features are/have been run So should @Before/After be renamed to @BeforeScenario/AfterScenario so that the intension of @Before/After is not lost? I'm happy to keep as is, just wanted to get that out there so we're clear. Thanks |
What @brasmusson said. Please create separate PRs for The former is much more likely to be accepted than the latter. We'll have to discuss that one with the maintainers of the other Cucumber implementations. Personally I'm sceptical about |
@mikquinlan, yes, that is what we'll have. |
Tests for using both at the same time can be added when both exist. I wouldn't sweat that yet :) |
Please keep PRs as minimal as possible. Then less things can go wrong in the approval process ;-) |
I genuinely appreciate your contribution @andryutz10, but I'm giving this the 👎 BeforeFeature / AfterFeature is an anti-pattern. See my comments in #515 about whether we really need BeforeAll / AfterAll anyway. |
@mattwynne, I agree with you on BeforeFeature/AfterFeature, as for the BeforeAll/AfterAll see my comments on #515, thats the reason why I split them in two different PR (see #678). |
Closing this. We'll only add |
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. |
Add new hooks for global level (@BeforeAll and @afterall) that run only once before all and after all existing features/scenarios, and new hooks for feature level (@BeforeFeature and @AfterFeature) that run only once before and after a feature(all scenarios in a feature file). Unit test and cucumber test to cover the new hooks and the running order between hooks.
An execution flow with the new hooks looks like this:
1 - @BeforeAll hook(s) (runs before all features once)
2 - @BeforeFeature hook(s) (runs before a feature, without tags or with tags for tagged features)
3 - @before hook(s) (no change, same behavior - before every scenario or tagged scenarios)
4 - @after hook(s) (no change, same behavior - after every scenario or tagged scenarios)
5 - .... 3 and 4 for all scenarios in a feature
6 - @AfterFeature hook(s) (runs after a feature without tags or with tags for tagged features)
7 - ....2 to 6 for every feature
8 - @afterall hook(s) (runs once after all the features are run)
As test for the new hooks see/run:
Added junit tests and cucumber tests for new code