Variable set with some value in the one cucumber step implementation is losing its value in the next step
@Test
Feature: Test
@test
Scenario: Test
When user sets value of varibale x
Then user retrives value of x
Step Implementation
import cucumber.api.java.en.When;
public class TestStepToBeRemoved {
String x;
@When("^user sets value of varibale x$")
public void setValueOfx() {
x = "Random Text";
}
@When("^user retrives value of x$")
public void retriveValueOfX() {
System.out.println("Value of X is : " + x);
}
}
This was working fine before we merged another framework in our project which uses Guice libraries and injectors. But Now output
Value of X is : null
So, is there any in cucumber that we can set the cucumber to clear all the object when step execution is completed?
Please dont ask for making x static, it will resolve this issue but we need any other solution except making x static