tags:

views:

210

answers:

2

I have JUnit tests that need to run in various different staging environments. Each of the environments have different login credentials or other aspects that are specific to that environment. My plan is to pass an environment variable into the VM to indicate which environment to use. Then use that var to read from a properties file.

Does JUnit have any build in capabilities to read a .properties file?

+1  A: 

Can't you just read the properties file in your setup method?

Nate
+5  A: 

java has built in capabilities to read a .properties file and JUnit has built in capabilities to run setup code before executing a test suite.

java reading properties:

Properties p = new Properties();
p.load(new FileReader(new File("config.properties")));

junit startup documentation

put those 2 together and you should have what you need.

pstanton