@TestPropertySource

From NovaOrdis Knowledge Base
Revision as of 23:09, 13 December 2018 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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() {
      ...
    }
}