In Droidium, there is abstraction of AndroidDevice via which I am doing almost anything with Android. I am producing AndroidDevice as ContainerScoped somewhere in StartContainer where I have container context.
In order to be able to have multiple Android devices in one test run, it obviously needs multiple abstractions of AndroidDevices.
This would not be problem if I interacted with AndroidDevice only in situations where I have container context. e.g while I am deploying and undeploying stuff to / from Android - Arquillian would give me “right” Android device injection according to which container context I am currently in.
The problem is that when Drone is about to destruct itself, the destruction is done somewhere in AfterClass but not in container undeployment phase where container context is activated and I would be good.
I am also using other helper classes which has AndroidDevice as runtime dependency and even these can be ApplicationScoped and have container scoped Android device in it (as a reference) so I am ok, I have problems when it comes to use these classes outside of container context in connection with multiple Android devices as is done in case of Selendroid destruction bound to Drone destruction which occurs outside of container context.
With existence of upcomming deployment scoped Drones, it would be possible to force Drones to destruct on BeforeUnDeploy so I would have right AndroidDevice however that means I would need to use @Drone @OperatesOnDeployment WebDriver everywhere …
Is there any better approach how to switch between container scoped android devices outside of container context?