I am testing a delegate class with Junit. When i right click on Run Configurations and put the key-value pair in Environment tab, it works fine.
I unsuccessfully tried to set it from a static block as well as @Before method. Can you help?
public MyClass{ public void myMethod(){ String tmp = configProps.getProperty("auto_commit_location"); String commitScriptLocation = System.getenv(tmp); System.out.println(commitScriptLocation); --- This returns null } } Junit Test: public class AutoCommitControlDelegateTest { static { System.setProperty("auto_commit_location", "/tmp/"); } @Autowired private ******* //calls to my methods
String commitScriptLocation = System.getenv(tmp);called? is it in a static block? a constructor? some other method?