我正在尝试 Geb (0.5.1) Grails (1.3.5) 集成。使用 JUnit 运行器(扩展 grails.plugin.geb.GebTests)时,Web 应用程序在执行 Geb 测试之前不会启动。因此测试失败,Firefox 说它无法在 localhost:8090 建立与服务器的连接。
在同一个测试应用程序中运行功能性 Selenium 测试(selenium-rc 1.0.2 插件)运行没有问题。
有人知道为什么在 Geb 功能测试之前没有启动 grails Web 应用程序,而在 Selenium 功能测试中它是正确启动的吗?
import geb.*
class GebTests extends grails.plugin.geb.GebTests {
void testIndexSearch() {
Browser.drive("http://localhost:8090/agora") {
go('/admin')
assert title == 'the title'
}
}
}
最佳答案
Browser.drive() 不应该是必需的。您是否尝试过以下操作?
import geb.*
class GebTests extends grails.plugin.geb.GebTests {
void testIndexSearch() {
go('/admin')
assert title == 'the title'
}
}
要设置 Grails 应用程序根以外的基本 URL,请添加:
String getBaseUrl() { "http://some/url" }
关于grails - Grails 中的 Geb 功能测试失败,因为尚未启动 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4423208/