@TestPropertySource

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

Test property sources have higher precedence than those loaded from the operating system’s environment or Java system properties as well as property sources added by the application declaratively through @PropertySource, programmatically or via @ConfigurationProperties. This is the recommended way to test behavior that depends on a specific system property value (or a set of system property values).

@RunWith(SpringRunner.class)
...
@TestPropertySource(properties = { "some.multi.level.property = 1", "some.other.multi.level.property = 2"})
public class ... {

    @Test
    public void someTest() {
      ...
    }
}