I have a variable and I want to pass this variable across all the steps. Anyone can suggest with an code snippet example please on how to pass a variable value between the steps please. Any help will be highly appreciated.
相关问题
- I receive the error: cannot find module 'cucum
- Port of the Rails app when running Cucumber tests
- Getting scenario and steps undefined in cucumber w
- How to output Cucumber background steps before eac
- How do I close() and quit() Selenium driver withou
相关文章
- How do you run cucumber with Scala 2.11 and sbt 0.
- How to pass multiple parameter to Cucumber Runner
- Donut report (donut-maven-plugin) is not getting g
- Cucumber not serializing date string from datatabl
- selenium grid with cucumber
- How to get scenario name from a scenario outline i
- Handling excel spreadsheets with Cucumber Scenario
- Tests on test(AVD) - failed: Instrumentation run f
In Cucumber for Java (cucumber-jvm) the intended way of sharing data between steps is to use a dependency integration (DI) container - several of which have been integrated with Cucumber.
The method in which you use DI varies slightly from container to container, but here's an example using PicoContainer:
The DI container will ensure that a single instance of MySharedData is created for each scenario and is passed to every step definition class that requires it. The benefit of this approach is that Cucumber ensures that no shared state leaks between scenarios, because the injected dependency is created afresh for each scenario.
The example above uses constructor injection (so the injected dependency is specified by a constructor parameter) but other DI containers also support other injection mechanisms, such as Spring's
@Autowired
.To get Cucumber to use DI you'll need to choose one (and only one) of the DI integrations and include it on your classpath (or in your POM). The choice is between:
You'll also need to install the selected DI container itself, because the Cucumber jars only provide the integration between Cucumber and the DI container.