Stefan Kendall
Stefan Kendall

Reputation: 67892

Getting at grails.serverURL in a unit test?

I've created a test-type for selenium types, and now I'd like to use grails.serverURL as the base url for the system under test.

Using ConfigSlurper on Config.groovy doesn't pick up the environmentally-conditioned grails.serverURL, and ConfigurationHolder.config is null.

How do I access grails.serverURL in unit tests? (Really my custom-test-phase that runs like a unit test)

Upvotes: 0

Views: 282

Answers (1)

Stefan Kendall
Stefan Kendall

Reputation: 67892

You need to pass GrailsUtil.environment to the ConfigSlurper constructor.

def config = new ConfigSlurper(GrailsUtil.environment).parse(new File('grails-app/conf/Config.groovy').toURL())

Upvotes: 2

Related Questions