I'm using a spring boot app which runs my src/main/resources/config/application.yml.
When I run my test case by :
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest
public class MyIntTest{
}
The test codes still run my application.yml file to load properties. I wonder if it is possible to run another *.yml file when running the test case.
See this: Spring @PropertySource using YAML
I think the 3rd answer has what you're looking for, i.e have a separate POJO to map your yaml values into:
Then annotate your test class with this:
A simple working configuration using
@TestPropertySource and properties
This might be considered one of the options. now if you wanted to load a yml file ( which did not get loaded by default on applying the above annotations) the trick is to use
Here is a sample code
Again make sure that the setup config java file - here
DataSourceTestConfig.java
contains the following property values.You can use
@TestPropertySource
to load different properties/yaml fileOR if you want to override only specific properties/yaml you can use