Search code examples
grailsfunctional-testing

Grails Functional Testing - grailsApplication.config is null within controllers and services


Grails 1.3.5

I've written a handful of functional tests and I'm running into issues when my controllers and services reference configuration data via grailsApplication.config. It is always coming back null, so it errors out.

I know there is a mockConfig for unit tests. But how do I get the config to get wired up for functional tests?


Solution

  • This is the hack that I have done for a while, there might be a better way though

    def filePath = new File('grails-app/conf/Config.groovy').toURL()
    def config = new ConfigSlurper(System.properties.get('grails.env')).parse(filePath)
    ConfigurationHolder.config = config