I have my Spring Boot main class:
@SpringBootApplication
@PropertySource("file:/my/file/properties")
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
//main method
}
I'm reading properties from an external file (using @PropertySource
). Now, I have an integration test:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes= Application.class)
@WebIntegrationTest
@TestPropertySource("file:/my/test/file/properties") // <---
public class MyTest {
//some tests
}
I need to use another external properties file, different from the indicated in @PropertySource
in Application
class. For that reason, I have added @TestPropertySource
, but seems that this annotation is not overriding the @PropertySource
.
What can I do?
Thanks in advance.
Use it this way:
@TestPropertySource(locations = "classpath:test.properties")
and place test properties file into src/test/resources
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With