I am using java in maven project for test automation. I have two properties files:
- DEV.properties (environment: DEVELOPMENT)
- PROD.properties (environment: PRODUCTION)
I read this properties:
private static final Properties properties;
private static final String CONFIG_PROPERTIES_FILE = "DEV.properties";
static {
properties = new Properties();
InputStream inputStream = Property.class.getClassLoader().getResourceAsStream(CONFIG_PROPERTIES_FILE);
try {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
In "CONFIG_PROPERTIES_FILE" variable I can indicate which environment I want to use (DEV or PROD). How to do the same with a terminal using maven? Something like:
private static final String CONFIG_PROPERTIES_FILE = $environment;
and in terminal:
mvn clean test $environment=DEV.properties
or:
mvn clean test $environment=PROD.properties