You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cleaning dependencies initialized by Google Guice container.
when working with selenium it is "cheap" to close and open a new WebDriver for every scenario (working with the existing "io.cucumber.guice.ScenarioScoped" option),
but when working with Appium it can take up 2-3 minutes for each session - in that case, we need to re-use the same session and install/uninstall the app to save this time.
there is no "session" scope Cucumber Guice - and also there is no "destroy" method similar to what spring+ cucumber has. so there is no way to terminate the object in case it's used in the entire session.
the easiest thing I think will be to detect if the scenario is last and perform cleanup on the last after hook and bind the object into an instance variable in order to re-use it in all of the scenarios.
✨ What's your proposed solution?
add a boolean check to the scenario e.g
@After
public void closeIosDriver(Scenario scenario) {
if (scenario.isLast()) {
iosDriver.quit();
}
}
⛏ Have you considered any alternatives or workarounds?
the alternative is bad - working with static variables all over the place and cleaning them in the afterAll static hook which is not available for Guice container
📚 Any additional context?
using the latest cucumber + Guice + Cucumber Guice dependencies.
Unfortunately I don't expect this will be possible in the short term. Cucumber itself currently has a lot of internal state (through thread locals) that would make passing a session object around impractical. There is some refactoring going on to clean that up but it is slow going.
The JUnit team also has plans to introduce session scoped resources so it would be nice if Cucumber could use those too. See:
So for now I do think it might be worth looking at a more sophisticated work around.
there is no "session" scope Cucumber Guice - and also there is no "destroy" method similar to what spring+ cucumber has.
So Spring keeps the application context running and only shuts it down when the JVM exits. It is kept in a static cache. You don't really see this because there is a nice framework wrapped around it.
the alternative is bad - working with static variables all over the place and cleaning them in the afterAll static hook which is not available for Guice container
You may want to consider putting all session variables in class and keeping a static reference to an instance of that class. Then inject that instance as needed with Guice and clean it up with a shutdown hook or fter all hook.
It's admittedly not as pretty as it can be, but I don't see a short term feasible solution otherwise.
Use your Appium session(s) inside a static ThreadLocal variable (works perfect when parallelism is enabled) and close it/them within an @afterall hook.
🤔 What's the problem you're trying to solve?
cleaning dependencies initialized by Google Guice container.
when working with selenium it is "cheap" to close and open a new WebDriver for every scenario (working with the existing "io.cucumber.guice.ScenarioScoped" option),
but when working with Appium it can take up 2-3 minutes for each session - in that case, we need to re-use the same session and install/uninstall the app to save this time.
there is no "session" scope Cucumber Guice - and also there is no "destroy" method similar to what spring+ cucumber has.
so there is no way to terminate the object in case it's used in the entire session.
the easiest thing I think will be to detect if the scenario is last and perform cleanup on the last after hook and bind the object into an instance variable in order to re-use it in all of the scenarios.
✨ What's your proposed solution?
add a boolean check to the scenario e.g
⛏ Have you considered any alternatives or workarounds?
the alternative is bad - working with static variables all over the place and cleaning them in the afterAll static hook which is not available for Guice container
📚 Any additional context?
using the latest cucumber + Guice + Cucumber Guice dependencies.
This text was originally generated from a template, then edited by hand. You can modify the template here.
The text was updated successfully, but these errors were encountered: