I'm wondering how to set up global variables in Citrus in pure Java. In Citrus documentnation there is a sample how to do this in XML but is there any way to do this in Java?
You can add these beans to the Spring application context using pure Spring Java configuration like this:
@Bean
public GlobalVariables globalVariables() {
GlobalVariables globalVariables = new GlobalVariables();
globalVariables.getVariables().put("myVar", "foo");
return globalVariables;
}
If you want to load a properties file and let Citrus convert these to global test variables you can use this bean in addition to the mentioned above.
@Bean
@DependsOn("globalVariables")
public GlobalVariablesPropertyLoader globalVariablesPropertyLoader() {
GlobalVariablesPropertyLoader globalVariablesPropertyLoader = new GlobalVariablesPropertyLoader();
globalVariablesPropertyLoader.getPropertyFiles().add("classpath:global.properties");
return globalVariablesPropertyLoader;
}