Grails 3: integration tests run in development environment, not in test environment

I split the database dataSourceConfig.yml configuration 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 

What I connect to the project in 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 through Intellij IDEA 15, it runs tests in the development environment, but there is test in the YAML configuration file.

Does anyone know how to fix this? The command below does not help.

 grails test test-app -integration 
+5
source share
1 answer

If you intend to run tests from the IDE, you need to change the launch configuration to include -Dgrails.env=test . You will want to do this for the default JUnit launch configuration, so you do not need to edit each test run configuration. Keep in mind that editing the default JUnit launch configuration will affect all configurations created in the future, but will not update existing configurations. You can delete all existing startup configurations so that they are re-created with the new settings the next time you run these tests.

+7
source

Source: https://habr.com/ru/post/1245541/


All Articles