I have steps definitions, let's say ClassA and ClassB, when in ClassB i want to use variable defined in ClassA.
Background:
Given Test environment is DEV
Then We get product info
ClassA()
Environment environment;//Enum like DEV("23.556.444.55", "44.555.666.77")
@Given("^Test environment is (.*)$")
public void setEnv(String name) {
//here i should define Env var (Enum)
environment = EnumClass.getEnvironment(name)
}
ClassB() {
@Then("^Then We get product info$")
public void getProdDetails() {
//Use here "environment" value defined in ClassA
}
}
How I can reach that, i believe to introduce any static is not a good approach.
I realize that ClassB should have a dependency ClassA so as a constructor injection Class A should be passed into ClassB as parameter but how "environment" field with defined value will be injected ?
Many thanks for any hints