I am trying to write unit tests for a service which use grailsApplication.config to do some settings. It seems that in my unit tests that service instance could not access the c
Go to http://ilikeorangutans.github.io/2014/02/06/grails-2-testing-guide
Grails’ config is usually accessed via an injected instance of GrailsApplication using the config property. Grails injects GrailsApplication into unit tests, so you can access it directly:
@TestMixin(GrailsUnitTestMixin)
class MySpec extends Specification {
private static final String VALUE = "Hello"
void "test something with config"() {
setup:
// You have access to grailsApplication.config so you can
//modify these values as much as you need, so you can do
grailsApplication.config.myConfigValue = VALUE
assert:
grailsApplication.config.myConfigValue == VALUE
}
}