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

Global hooks before after all #678

Merged

Conversation

@andryutz10
Copy link
Contributor

commented Mar 4, 2014

Add new hooks for global level (@BeforeAll and @afterall) that run only once before all and after all existing features/scenarios. 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 - @before hook(s) (no change, same behavior - before every scenario or tagged scenarios)
3 - @after hook(s) (no change, same behavior - after every scenario or tagged scenarios)
4 - .... 2 and 3 for all scenarios in a feature
5 - @afterall hook(s) (runs once after all the features are run)
As test for the new hooks see/run:
cucumber.runtime.java.hooks.RunWithAllHooksTest
cucumber.runtime.java.hooks.HooksStepDefs
test\resources\cucumber\runtime\java\hooks\feature-1.feature
test\resources\cucumber\runtime\java\hooks\feature-2.feature
Added junit tests and cucumber tests for new code
This PR is for @BeforeAll/@afterall global hooks, is from the split of #672 into @BeforeAll/@afterall hooks and @BeforeFeature/@AfterFeature hooks. I'll have another PR for the @BeforeFeature/@AfterFeature hooks.

andryutz10 added some commits Mar 4, 2014

Add new hooks for global level (@BeforeAll and @afterall) that run on…
…ly once before all and after all existing features/scenarios. 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 - @before hook(s) (no change, same behavior - before every scenario or tagged scenarios)
3 - @after hook(s) (no change, same behavior - after every scenario or tagged scenarios)
4 - .... 2 and 3 for all scenarios in a feature
5 - @afterall hook(s) (runs once after all the features are run)

As test for the new hooks see/run:

cucumber.runtime.java.hooks.RunWithAllHooksTest
cucumber.runtime.java.hooks.HooksStepDefs
test\resources\cucumber\runtime\java\hooks\feature-1.feature
test\resources\cucumber\runtime\java\hooks\feature-2.feature
Added junit tests and cucumber tests for new code
Add new hooks for global level (@BeforeAll and @afterall) that run on…
…ly once before all and after all existing features/scenarios. 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 - @before hook(s) (no change, same behavior - before every scenario or tagged scenarios)
3 - @after hook(s) (no change, same behavior - after every scenario or tagged scenarios)
4 - .... 2 and 3 for all scenarios in a feature
5 - @afterall hook(s) (runs once after all the features are run)

As test for the new hooks see/run:

cucumber.runtime.java.hooks.RunWithAllHooksTest
cucumber.runtime.java.hooks.HooksStepDefs
test\resources\cucumber\runtime\java\hooks\feature-1.feature
test\resources\cucumber\runtime\java\hooks\feature-2.feature
Added junit tests and cucumber tests for new code
Add new hooks for global level (@BeforeAll and @afterall) that run on…
…ly once before all and after all existing features/scenarios. 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 - @before hook(s) (no change, same behavior - before every scenario or tagged scenarios)
3 - @after hook(s) (no change, same behavior - after every scenario or tagged scenarios)
4 - .... 2 and 3 for all scenarios in a feature
5 - @afterall hook(s) (runs once after all the features are run)

As test for the new hooks see/run:

cucumber.runtime.java.hooks.RunWithAllHooksTest
cucumber.runtime.java.hooks.HooksStepDefs
test\resources\cucumber\runtime\java\hooks\feature-1.feature
test\resources\cucumber\runtime\java\hooks\feature-2.feature
Added junit tests and cucumber tests for new code

@aslakhellesoy aslakhellesoy merged commit 34332ef into cucumber:master Jun 26, 2014

1 check passed

default The Travis CI build passed
Details

aslakhellesoy added a commit that referenced this pull request Jun 26, 2014

aslakhellesoy added a commit that referenced this pull request Jun 26, 2014

@aslakhellesoy

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2014

Unfortunately I had to revert all of this. It turns out that it doesn't work when you use DI, or if a BeforeAll hook fails.

I think BeforeAll java hooks should only work for static methods. It should be an error to put the annotation on non-static methods.

Alternatively, they can be non-static, but then we have to create a separate world for BeforeAll and AfterAll (a world is needed in order to instantiate objects with DI). This will be easier to do when we have Gherkin3, which will let us create a much simpler runtime model than what we have now.

@lock

This comment has been minimized.

Copy link

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.
Projects
None yet
2 participants
You can’t perform that action at this time.