I have a Grails 3 application that I'm trying to configure an embedded datastore for functional tests for. I have the configuration for the datastore specific to the 'test' environment.
When I run 'grails test-app', the app connects to the correct datastore and my functional tests pass.
When I try testing the application with 'gradle test', it tries to connect to the datastore for the development environment and fails.
I have tried specifying the Grails environment to use for the gradle test task by adding this to build.gradle:
test {
String testEnvArg = '-Dgrails.env=test'
if (jvmArgs) {
jvmArgs.add(testEnvArg)
} else {
jvmArgs = [testEnvArg]
}
}
But the behavior appears to be unchanged.
How can I make the gradle 'test' task use the correct Grails environment configuration?
You must specify environment:
gradle -PgrailsEnv=test test
To boot run with production environment and gradle wrapper below worked:
./gradlew -Dgrails.env=production bootRun
And with requested test environment:
./gradlew -Dgrails.env=test bootRun
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