It seems that Grails 2.x tests already have a config
object. Therefore enough to say
config.some.config.setting = 'foo'
which will then be available from the @TestFor
test object.
If you need to create an object manually, then the test also has a grailsApplication
object in the object area to which the config
object belongs. So this should work -
config.some.config.setting = 'foo' def myService = new MyService(grailsApplication:grailsApplication)
source share