Ho separato dataSourceConfig.yml
database di file di configurazione:Grails 3: test di integrazione vengono eseguiti in un ambiente di sviluppo, non in un ambiente di test
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
che mi collego al progetto nel 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))
}
}
Quando eseguo test di integrazione tramite Intellij IDEA 15, esegue test in un ambiente di sviluppo , ma il file di configurazione YAML ha la sezione test .
Qualcuno sa come risolvere questo problema? Il comando qui sotto non aiuta.
grails test test-app -integration
Cosa succede se si esegue 'grails -Dgrails.env = test test-app -clean -integration'? – saw303
@ saw303 Quando si eseguono i test usando 'grails' o' gradle', non è necessario specificare '-Dgrails.env = test'. Questo dovrebbe essere richiesto solo quando si esegue dall'IDE usando le informazioni di configurazione di esecuzione integrate dell'IDE. –
'grails test test-app -integration' non è valido. Probabilmente vorrai l'integrazione test-app di 'grails:' o './gradlew iT'. –