Set java system properties in IntelliJ or Eclipse

吃可爱长大的小学妹 提交于 2019-12-02 23:36:58

In InteliJ goto "Run"->"Edit Configurations" In the new window, right panel, open the Junit and click on your test. Now, in the middle click on the "Configuration" tab and update the "VM options"

Note that you will need to do this for every test class, but you can remove all the test from the junit in the right panel and update it in the "Defaults"

In IntelliJ it works as follows: Go to configurations -> VM options and add the parameter/value pair:

-DmyParameter=value

Make sure you add a "D" after the "-"!

If you are like me, and showed up here trying to run tests that use the -P syntax instead of -D syntax, you can simply follow the instructions from MZF, but use the -D in place of the -P.

For example, my test on the command line executed as:

./gradlew -Penvironment=qa project:test

Using the -P in intellij on the VM line got rejected. Changing the -P to a -D ended up working, however.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!