intellij-ideaenvironment-variables

Setting up and using environment variables in IntelliJ Idea


I set up an environment variable (Under IDE Settings -> Path Variables)

 APP_HOME = /path/to/app_home  

One of my tests is failing however with

 System.out.println("APP HOME: " + APP_HOME); 

With

 APP HOME: null/ 

It does not look like that env variable is being read. What am i missing?


Solution

  • Path Variables dialog has nothing to do with the environment variables.

    Environment variables can be specified in your OS or customized in the Run configuration:

    env

    If you want to specify default environment variables for every new unit test configuration (as per this answer):

    Run > Edit Configurations > Edit Configuration Templates > TestNG/JUnit > Environment Variables