Is it possible to share data between scenario and features in Cucumber
There is no cucumber feature for that. There is helper Background
cucumber background, that will execute some steps before each scenario in the feature. You can have a look into that.
Seems related How to share state between scenarios using cucumber
Seems related as well: how-to-pass-variable-values-between-cucumber-jvm-scenarios
Related videos on Youtube
alex
Updated on June 04, 2022Comments
-
alex almost 2 years
I have separate class with static variable (e.g. List“<”Company“>”) that i need to share between tests (e.g. get, add or remove companies from list). But when a new scenario starts the data is re-initialized. Notes: the class is in separate folder, it doesn't has Cucumber hooks, and its object isn't created anywhere in cucumber classes.
Maybe there is some analog of ScenarioContext like in SpecFlow?
PS: i know that sharing data from test to the other is a bad approach, but in my specific case it doesn't corrupt test independency
-
Grasshopper over 7 yearsHow are you instantiating the static List? Just do it the first time with a static flag and set flag to false so the List data will be persisted. Can you add the current instantiation code?
-
user861594 over 7 yearsyou can check with QAF-gherkin. It has different data and configuration management features, you can hold company list in xml as well and use it anywhere.
-