Currently, we have time to update the architecture in our test automation framework, and we are searching for the best solution to our needs.
We have this module architecture:
tests-core
core-api
core-web
tests-products
tests-product1-api
tests-product1-web
tests-product2-api
tests-product2-web
We have common functionality for all products: classes, pages, and step definitions in core. Yes, they are very similar.
In tests-products modules, we have overridden implementations for the relevant products also unique functionality for this product.
Web modules are dependent on API modules.
Each test-product module has tests only for this one product.
We use the DI
framework, Guice
, for binding the appropriate class for the product.
And the problem is that we can bind functionality only for one product at once. If we want to have cross products tests in new tests-products:tests-crossproducts-api/web
, then we must rebind all classes each time when we change products during one test.
When this framework was created, there was no need to run such tests, which is why we want to change it.
And now, we want to create and hold objects for two products at once in our cross products test. DI frameworks don't allow it.
Maybe someone has similar problems; how do you resolve them?
Maybe someone knows some design patterns which allow us to do such things? Currently considering such patterns as Decorator and Strategy, but as I see it, Strategy allows us to use one behavior at the same time. Decorator is something that might suit us, but I didn't find an excellent example of how we can do it.
Maybe we can create two contexts and use them use at the right time, and there is some framework for this?
Maybe there is another way we can achieve our needs?