I have written a cucumber integration tests and it is running ok.
And then i wanted some class variables from the step.java to get their values from .properties values
public class cucumberStepClass {
@Value("${value.from.propertiesfile}")
private String variable
//rest of integration test
}
Does anyone know how can i inject those values so my test can use them?
Properties props=new Properties(); To read the file we have to use the Java Filereader and set the path of the properties file. FileReader reader=new FileReader("file path"); Then we have to load the File into the properties using the load method.
The Properties file can be used in Java to externalize the configuration and to store the key-value pairs. The Properties. load() method of Properties class is convenient to load . properties file in the form of key-value pairs.
Have you enabled integration with spring dependency injection? You need to add the cucumber-spring
dependency for that. See https://docs.cucumber.io/cucumber/state/#spring
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With