0

I have a problem and I can't load a YML in the main tests. I currently have an application.yml in the src > main > resources > config > application.yml path and I want it to take the src > test > resources > config > application-test.yml

I already tried using @ActiveProfiles("test"), but take the main route. I also tried @Profile("test") but it does nothing different.

I also tried simply to create the application.yml in the path src > test > resources > config > application.yml

Also put the annotation:

@SpringBootTest(
        properties = ["spring.profiles.active=test"],
        classes = Application.class,
)

Anyone knows how to solve this?

jdflores
  • 407
  • 7
  • 25
  • Have you checked this https://stackoverflow.com/a/53134737/5790498? – Abhijeet Feb 18 '20 at 13:45
  • Does this answer your question? [Load different application.yml in SpringBoot Test](https://stackoverflow.com/questions/38711871/load-different-application-yml-in-springboot-test) – Abhijeet Feb 18 '20 at 13:45
  • @Abhijeet Yes, is the same question but I tried everything they say and nothing worked. – jdflores Feb 18 '20 at 13:56
  • @jdflores, you need to do one of these 1. move the file up from src/test/resources/config to src/test/resources 2. add @PropertySource() to specify the path to the properties The default location for properties in a maven project structure is src/[main/test]/resources. HTH – sandboxbohemian Feb 18 '20 at 14:07
  • @sandboxbohemian I already tried to change the application.yml and it still doesn't work. I also tried the PropertySource() but read that it doesn't work for .YML files – jdflores Feb 18 '20 at 15:49
  • Can you please have look at this. https://memorynotfound.com/spring-boot-managing-profiles-profile-annotation-example/ – Bhaumik Thakkar Feb 19 '20 at 07:09

0 Answers0