I have separated dataSourceConfig.yml
database config file:
environments:
development:
dataSource:
dbCreate: none
url: jdbc:oracle:thin:xxxxxx
driverClassName: oracle.jdbc.OracleDriver
dialect: org.hibernate.dialect.Oracle10gDialect
username: xxxx
password: xxxx
test:
dataSource:
dbCreate: none
url: jdbc:oracle:thin:xxxxx
driverClassName: oracle.jdbc.OracleDriver
dialect: org.hibernate.dialect.Oracle10gDialect
username: xxxxx
password: xxxxx
Which I connect to the project in the Application.java
:
class Application extends GrailsAutoConfiguration implements EnvironmentAware {
static void main(String[] args) {
GrailsApp.run(Application, args)
}
@Override
void setEnvironment(Environment environment) {
String configPath = environment.getProperty("local.config.location")
Resource resourceConfig = new FileSystemResource(configPath)
YamlPropertiesFactoryBean ypfb = new YamlPropertiesFactoryBean()
ypfb.setResources([resourceConfig] as Resource[])
ypfb.afterPropertiesSet()
Properties properties = ypfb.getObject()
environment.propertySources.addFirst(new PropertiesPropertySource("local.config.location", properties))
}
}
When i run integration tests via Intellij IDEA 15, it runs tests at a development environment, but the YAML config file has test section.
Is anyone knows how to fix this? The command bellow doesn't help.
grails test test-app -integration
If you are going to run tests from the IDE you need to modify the run config to include -Dgrails.env=test
. You will want to do that for the default JUnit run config so you don't have to edit every single test run config. Be aware that editing the default JUnit run config will affect all configs that are created in the future but will not update any existing configs. You may want to remove all of the existing run configs so they will be recreated with the new settings the next time you run those tests.
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