简体   繁体   中英

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)

您需要将GrailsUtil.environment传递给ConfigSlurper构造函数。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM