Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 223
Christian Neverdal Avatar asked Sep 24 '15 11:09

Christian Neverdal


People also ask

How do I set environment variables in IntelliJ?

From the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog, select a configuration you want to add the environment variables to. Type the variable name and value: <name>=<value> .

Where are environment variables stored in IntelliJ?

Click edit configurations on the dropdown box for your runtime configurations. Select the runtime you want to add environment variables to. Click environment variables folder icon to pull up the environment variables screen.


1 Answers

Select Run > Edit Configurations..., open the Defaults(Templates since IDEA 2020) node in the left tree and select JUnit. Now add your environment variables in the main panel and click Apply or OK. From now on, those variables will be added to every new JUnit run configuration in your project.

enter image description here

like image 141
Darek Kay Avatar answered Sep 28 '22 14:09

Darek Kay