intellij-ideajunit

In IntelliJ, how do I set default environment variables for new test configurations?


My JUnit tests require three environment variables to be set. It is infuriating to have to set these for each new test class.

How can I avoid this?


Solution

  • Select Run > Edit Configurations... then on the bottom-left of the dialog click Edit Configuration Templates in the left pane select JUnit then in the right use Environment Variables: to add your environment variables. Click Apply or OK. From now on, those variables will be added to every new JUnit run configuration in your project.

    Top Tip If you click the Edit environment variables, you can paste multiple env variables at once like this:

    FOO=bar
    BAR=foo
    

    Run/Debug Configurations