-
-
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
Before/After feature hooks and hacks #914
Comments
I don't understand. Can you please give more detail around this? You could create an
Again, I don't understand this, please explain more. You should be able to use an After hook, but you do lose the context of whether or not this is the last one. Ideally you don't need to do any teardown here. Also you are trying to make scenarios be connected which is discouraged. I would suggest one of the following:
|
To be clear, the workaround I'm referring to is:
Consider some features:
If they are run in the order above, the teardown won't happen between feature 1 and feature 2. The teardown won't happen after feature 4 either because there will be no other test matching ~@featurehook (admittedly this can be fixed with AfterAll). I am not trying to make scenarios connected, for me it is being free to decide on a tradeoff between isolation and performance. Take the example of a test that sets up a test SMTP server with different configurations:
There may be side effects between scenarios by not tearing it down, but the trade-off between purity and performance might be worth it in this case. |
Sorry but this isn't something I think should be supported. There is the ability to share state across all scenarios and across a single scenario which covers the vast majority of cases. Your example in the last comment (with @featurehook) isn't solved by having BeforeFeature / AfterFeature anyway. |
+1 for BeforeFeature/AfterFeature hooks |
Since I use a service like Browserstack, which is perpetually slow and painful to work with (and so are other remote server providers like Saucelabs), I normally use BeforeFeature and AfterFeature event handlers to setup selenium sessions and teardown per feature file. Therefore, the scenarios related to that feature mentioned in my file run together and to start afresh post each scenario, I refresh the browser screen and the state of my app is refreshed for my tests. So in a way they are isolated and it also does not affect the test performance. This should be considered as a case to bring the Before/After feature hooks back to be used than executing cucumberjs per feature file as suggested above. |
The major "competitors" of Cucumber support this (e.g. JBehave, RobotFramework), and without any hacks; it's a proper feature of the framework. This issue is definitely a blocker for using Cucumber. |
Hi... I am facing an issue related to this. In my case, I use tagged Before and After hooks to create/delete data that will be used to test the UI. In the Before hook I hit an API endpoint and create the data, and in the After hook I hit another API endpoint to delete it (I save the objects' id's returned in the create response, and then I build the delete payload with those id's) The problem is that, when the scenario that uses that data (and triggers the hooks) is the last to be executed, the after hook never gets triggered... Any way to workaround this?? Thanks |
+1 for Before and After Feature. We want to tag a feature like so: @ie-8-only
Business Need: IE8 should have limited functionality, but what is displayed, should be displayed correctly
@no-access @ssl-insecurity @security @BUG-1876
Scenario: No access
Given I am on the home page
When I see that my browser is not supported
Then I should not be able to access the core site functionality
@formatting-issue @bugs @BUG-1210
Scenario: The menu should not be formatted like a staircase
For the users to be able to navigate to the about us / contact us area of the site, the site navigation should be active
Given I am on the home page
When I see the menu
Then it should be displayed in a line This will allow us to close the browser and open IE in a BeforeFeature hook, and reopen the browser we are using for the rest of the suite in the AfterFeature hook. Closing and reopening the browser takes a lot of time when you are doing it for every Scenario, which would make this a great feature to use. Note: There are other times where you might want to attach text to the Feature as an added description for it in a BeforeFeature Hook, which is another example of where this would be useful |
I think as well before/after feature hooks would be useful on certain types of tests. For example Specflow, the Cucumber library for .NET, has these implemented: |
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. |
I understand the reasoning behind not having BeforeFeature/AfterFeature feature hooks. Tests should ideally be isolated. However, for practical performance reasons it can be preferable to setup things like database fixtures once per feature.
The workaround specified in #614 is inadequate because:
Previous to 3.0.0 it was possible to hack in this functionality using the context passed as the first argument of registerHandler('BeforeFeatures').
Any thoughts on accepting a PR for this functionality, or providing a similar context in 3.0 to at least make the hack possible again?
The text was updated successfully, but these errors were encountered: