Specifying a custom log4j.properties file for all of JUnit tests run from Eclipse

后端 未结 2 1518
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 07:51

I would like to specify a specific Eclipse VM argument to all of the JUnit tests I run from Eclipse i.e.

-Dlog4j.configuration=log4j-dev.propert         


        
2条回答
  •  清歌不尽
    2020-11-27 07:57

    Eclipse gives you the ability to define default VM arguments that are applied to any launch which uses that VM. You could use that in your situation by defining a JRE configuration with the VM argument you want for log4j and then setting up all JUnit launches to use that JRE definition.

    In Preferences, Java > Installed JREs and use the Add... button to define a JRE. In the JRE Definition dialog there is a field for Default VM arguments. Give this JRE definition a useful name such as "JDK 7 for JUnit" so that you can easily identify it.

    enter image description here

    Then in your JUnit launch(es), on the JRE tab, select the JRE definition you created.

    enter image description here

提交回复
热议问题