Spring 2.4.5.
Gradle 6.5.1.
There are placeholders in PostgreSQL connection string in application.properties
file under test folder.
spring.datasource.initialization-mode=always
spring.datasource.platform=postgres
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://${PG_HOST}:${PG_PORT}/
spring.datasource.username=postgres
spring.datasource.password=password
spring.datasource.max-size=5
In order to make tests working, I've added the following lines to build.gradle
file:
test {
...
systemProperty "PG_HOST", System.getProperty("PG_HOST")
systemProperty "PG_PORT", System.getProperty("PG_PORT")
...
}
So, I'm able to tun test via command line as follows:
./gradlew test -DPG_HOST=localhost -DPG_PORT=5432
Then, I decided to run Gradle test task via IntelliJ Idea Gradle pane.
I've added
PG_HOST
& PG_PORT
as environment variables.
But the env variables are not being passed to Gradle test config, and test fail.
Any ideas on this matter?