36

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?

1 Answer 1

71

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

3
  • This would be defaults for this project only?
    – nevets1219
    Commented Dec 14, 2016 at 2:29
  • 4
    @nevets1219 I just tested it - this seem to be only project defaults. Commented May 5, 2018 at 13:42
  • 4
    For version 2020 at least it's Templates instead of Defaults Commented Jan 19, 2021 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.