Call for action: Share usage patterns of Before/After Feature hook and FeatureContext #468
Replies: 7 comments 5 replies
-
This codebase does not exist anymore, I think. But we used it once to enable or disable messages within an event sourced system by adding tags to the feature and reading those in the hooks. Mainly as a switch to speed up execution of scenarios that did not depend on the messages. Though technically we could implement that on the scenario level hooks as well, it was easier to deal with at the feature level. So there was a use case, but if the feature was to be removed or would not prohibit implementation. |
Beta Was this translation helpful? Give feedback.
-
Would obsoleting |
Beta Was this translation helpful? Give feedback.
-
We use it to share certain cloud resources across the lifetime of a Feature. That way we don't have to pay the cost of creating and deleting them for every scenario of a feature. For example, we register a "resource tracker" to the DI container in the [BeforeFeature], then we create the resources (once) using Givens in the "Background:", and only clean them up in the [AfterFeature] after all scenarios are done. |
Beta Was this translation helpful? Give feedback.
-
We are currently still using Specflow, but i have started a branch with the migration to reqnroll already, which is currently dormant, since i couldnt find a solution on how to generate a livingdoc as html with reqnroll yet. We use the
We also use the
We do the same again for
|
Beta Was this translation helpful? Give feedback.
-
We have a test suite that uses Appium to test a native mobile app. The features run in parallel. We could move the logic to Before/After scenario, but it made sense to use feature hooks because we run features in parallel. |
Beta Was this translation helpful? Give feedback.
-
We inherited a large API test suite where data setup is expensive. To reduce execution time we introduced a cache to reuse data for non-destructive tests (such as tests that verify 400, 401, 404, ...). The cache is created in a BeforeFeature hook. If the cache is empty the test will perform the set up and store the result. If the cache is not empty, the test will skip the set up and reuse the data in the cache. Data is cleaned up and removed when a test fails and at the end of the feature (in an after feature hook). That caching approach might be a bit of an anti-pattern but it was a relatively easy thing to implement for a quick win. I think the AfterFeature hook is necessary to support this pattern because we need to clean up the data after the last scenario runs in the feature. |
Beta Was this translation helpful? Give feedback.
-
We use BeforeFeature hooks to register global resources (things we only want one instance of per test run) into the container in the TestThreadContext. Examples of global resources:
|
Beta Was this translation helpful? Give feedback.
-
Through the last year we had many discussions about the concept of
FeatureContext
and the way how before/after feature hooks work. With the broader introduction of scenario (method) level parallel execution, the question became even more important.The behavior of the feature context and the related hooks have been inherited from SpecFlow, but it has turned out that the behavior is not obvious and leads to many misunderstandings. Also this concept is considered to be a problematic by many BDD practitioners - in other Cucumber implementations there is no such concept.
Also make sense to note that keeping the concept of
FeatureContext
increases the complexity of Reqnroll quite a lot and causing ongoing efforts.Because of all these I thought it would make sense to kick-off a discussion for the future of this concept.
However through the preliminary discussions I have realized that many of us, including myself do not use this concept anyway so we are discussing based on "imagined usage scenarios" that is very dangerous. (I have checked my codes back to 10 years and haven't found any usage of the feature context or the related hooks.)
So here is a call for action: 📢 Please briefly describe your usage of the
FeatureContext
and the before/after feature hooks here as a comment. Please make sure you describe only real usage scenarios, not wishes or imagined situations (there will be a round when we collect those, but not now).We are interested in why you use these features, what actions you perform in before/after hooks and what do you store in the feature context. Every usage should be a new top-level comment here and we might ask back for clarifications in the sub-comment of these.
Beta Was this translation helpful? Give feedback.
All reactions