Automatically add properties when running JUnit in Eclipse

后端 未结 5 900
猫巷女王i
猫巷女王i 2021-02-04 05:08

In order to run my unit tests on my Eclipse, I need to set some properties for the VM.

Thus, when I first run my JUnit test, I go in \"Open Run Dialog\", then in my JUni

5条回答
  •  臣服心动
    2021-02-04 05:44

    When i want to set some properties entries for my junit test i implement the following

    protected void setUp() throws Exception {
            super.setUp();
    
            System.setProperty("Property1", "value1");
            System.setProperty("Property2", "value2");
    }
    

    The properties are set before the test methode is called

    EDIT: You also can read the properties from a file and at thes to the System properties

提交回复
热议问题