Grails with Geb / Spock:Grails不接受我的baseUrl

时间:2013-06-07 08:47:54

标签: grails spock geb

我正在使用Grails 2.2.1和最新的Geb版本。我的Spec测试文件在 功能/ com.geb.mytest /

我的GebConfig与我的Specs在同一个包中。

import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile

driver = {
    FirefoxProfile firefoxProfile = new FirefoxProfile()
    new FirefoxDriver(firefoxProfile)
}

reportsDir = "target/test-reports"
baseUrl =  'http://myserver.com'

waiting {
    timeout = 5
    retryInterval = 0.5

    presets {
        slow {
            timeout = 20
            retryInterval = 1
        }
        quick {
            timeout = 1.5
            retryInterval = 0.3
        }
    }
}

environments {
}

当我运行grails test-app -functional时,我的baseUrl没有被考虑...而是我有一个localhost网址..

有没有办法避免将baseUrl作为参数添加到grails test-app命令中?

有什么想法吗? 提前致谢

1 个答案:

答案 0 :(得分:1)

尝试在类中设置baseUrl,该类扩展用于您拥有的每个测试类:

class BaseUrlTest extends GroovyTestCase {

    def baseURL

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        baseURL = 'your url here'
    }

}

然后你的测试类看起来像这样

class myTests extends BaseUrlTest {
    void testSomething() {}
}
相关问题