0

I'm writing integration tests, and I'd like to use Spring profiles to configure properties for each environment. However I'm finding profile specific application properties (e.g. application-dev.yml, application-prod.yml) in my src/test/resources directory aren't activated the same way they are in src/main/resources. It appears running tests with -Dspring.profiles.active=prod has no effect. Is it possible to activate a profile from the command line for tests?

Note: @ActiveProfiles isn't sufficient because I want to run the same tests against multiple environments.

pnewhook
  • 4,048
  • 2
  • 31
  • 49

2 Answers2

0

I don't know if you have copied the file names from your workspace but 'applicaiton-prod.yml' has a typo in it. That could be the reason.

Anand Kulkarni
  • 1,131
  • 1
  • 7
  • 7
0

I found a similar issue reported in GitHub and the solution was applicable to my problem. The JVM system property spring.profiles.active wasn't getting picked-up in Gradle. So I modified my task as follows

integrationTest {
    systemProperties = System.properties
}
pnewhook
  • 4,048
  • 2
  • 31
  • 49