Override default Spring-Boot application.properties settings in Junit Test with dynamic value

前端 未结 4 1707
挽巷
挽巷 2020-12-10 16:56

I want to override properties defined in application.properties in tests, but @TestPropertySource only allows to provide predefined values.

What I need is to start a

4条回答
  •  既然无缘
    2020-12-10 17:20

    You could override the value of the port property in the @BeforeClass like this:

    @BeforeClass
    public static void beforeClass() {
        System.setProperty("zookeeper.port", getRandomPort());
    }
    

提交回复
热议问题