0

I am implementing integration tests and I have a problem with overriding custom properties that my application use.

Integration test sample:

@RunWith(SpringRunner.class)
@SpringBootTest(
    classes = Application.class,
    webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
)
@TestPropertySource(locations = "classpath:test.properties")
public abstract class BaseIntegrationTest {

    @Autowired
  protected TestRestTemplate restClient;

The @TestPropertySource(locations = "classpath:test.properties") will override application.properties of my application with one that is provided

However, my application use custom property file like this:

@Configuration
@PropertySource("classpath:fileProvider/custom.properties")
@ConfigurationProperties(prefix = "com.sample.config")
public class SampleProviderConfigProperties {

In my application there is many external providers. Each of them like SampleProviderConfigProperties has with it's own configuration

In integration tests I would like to replace the provider custom.properties with configuration for test systems.

Is there any way to achieve that ?

Aleydin Karaimin
  • 944
  • 1
  • 6
  • 16

0 Answers0